diff --git a/demo/App.vue b/demo/App.vue index ba6ba16..ba91c5e 100644 --- a/demo/App.vue +++ b/demo/App.vue @@ -1,13 +1,12 @@ @@ -16,7 +15,7 @@ eventBus.$on((value) => {

{{ testValue }}


-

{{ eventBus.$state.value }}

+

{{ notifier.$state.value }}

diff --git a/demo/ChildComp.vue b/demo/ChildComp.vue index b6d388b..371a7f1 100644 --- a/demo/ChildComp.vue +++ b/demo/ChildComp.vue @@ -1,9 +1,10 @@ diff --git a/demo/composables/eventBus.ts b/demo/composables/eventBus.ts deleted file mode 100644 index 5db3e33..0000000 --- a/demo/composables/eventBus.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { useSubscription } from '../../src/subscription'; - -const myEventBus = useSubscription(0); - -export function useEventBus() { - return { - $on: myEventBus.$addSub, - $off: myEventBus.$deleteSub, - $emit: myEventBus.$set, - $state: myEventBus.$read - }; -} diff --git a/demo/composables/notifier.ts b/demo/composables/notifier.ts new file mode 100644 index 0000000..05d3673 --- /dev/null +++ b/demo/composables/notifier.ts @@ -0,0 +1,12 @@ +import { useSubscription } from '../../src/subscription'; + +const notifier = useSubscription(0); + +export function useNotifier() { + return { + $on: notifier.$addSub, + $off: notifier.$deleteSub, + $emit: notifier.$set, + $state: notifier.$read + }; +} diff --git a/package.json b/package.json index 7afbf99..0ea07c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-subscription", - "version": "0.0.9", + "version": "1.0.0", "description": "A type-safe 🔥 & tiny ⭐️ super-charged ref ⚡️ / eventBus replacement in Vue 💚.", "keywords": [ "web", diff --git a/scripts/release/releaseData.json b/scripts/release/releaseData.json index 809a54d..21802d1 100644 --- a/scripts/release/releaseData.json +++ b/scripts/release/releaseData.json @@ -1,4 +1,4 @@ { "onGoing": false, - "version": "0.0.9" + "version": "1.0.0" } \ No newline at end of file diff --git a/src/subscription.ts b/src/subscription.ts index 476aeed..1c9d839 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -2,8 +2,9 @@ import { dynamicallyExecuteFunction } from './functions/helpers'; import { ref, shallowRef, readonly } from 'vue'; /** - * It takes a value and returns an object with a value property that is a shallowRef/ref of the value. - * passed in, and Subscribers(function) are added to a list to be executed when the value is changed. + * It takes a value and returns an object with a value property that is a shallowRef/ref of the value + * passed in and Subscribers(function) are added to a list to be executed when the value is changed. + * @example useSubscription(value: T, deep = false) * @param {T} value - T - The initial value of the subscription. * @param {boolean} deep - T - If it should be deep reactivity. By default it is Shallow. * @returns A function that returns an object with a shallow/deep reactive value, a subscriber and a @@ -78,7 +79,7 @@ export function useSubscription(value: T, deep = false) { else setValue(val); }, - /** ReadOnly version of value. Wraps the shallow ref in readonly */ + /** ReadOnly version of value. Wraps the ref in readonly */ $read: readonly(_subRef), /** @@ -108,7 +109,7 @@ export function useSubscription(value: T, deep = false) { */ $mutate(mutator: ValueMutator) { if (typeof _subRef.value !== 'object') { - throw new Error('Value passed is not an typeof object! Patch only accepts typeof object'); + throw new Error('Value passed is not an typeof object! $mutate only accepts `typeof object`'); } mutateSubscriber(mutator); }