-
Notifications
You must be signed in to change notification settings - Fork 0
Reactivator API
This library package includes a small number of methods that provide reactivity for data elements. While modeled after Vue, it is framework-agnostic and should support any data, stored anywhere. However, the naming of methods will clash with those in Vue, and likely other frameworks, and since it provides a subset of other frameworks, it is assumed that this package will not be used in combination with other frameworks, at least within the same modules.
ref(data)
- wraps a simple scalar data element (such as a number or string) with an object that provides reactivity to that element.
reactive(obj)
- replaces (returns) an object (with several members) with a Proxy object that provides reactivity to changes to that element.
computed(data, func)
- returns a reactive reference (via .value
) that accepts an arbitrary function to provided the evaluation.
isRef(thing)
- returns true if the parameter was previously returned from a call to ref()
above.
isReactive(thing)
- returns true if the parameter was previously returned from a call to reactive()
above.
isComputed(thing)
- returns true if the parameter was previously returned from a call to computed()
above.
watch(data, func)
- watches data
(which was returned from either ref
or reactive
above) for any changes and invokes the handler (func
) supplied.
unwatch(data, func)
- removes a previous watch on data
where the handler supplied (func
) matches the original watch
.
dumpValue(thing, objToJSON)
- a convenience function that accepts a variable of any kind and returns a simple text string representation for reporting. If the optional objToJSON
parameter is provided and is truthy, an objects encountered will be returned as a JSON string rather than "[object Object]".