A Set like structure that's observable
npm install observ-set
var observSet =var observ =var isObserv =var set =setsetsetset// Transactional as wellset
Creates a new
ObservSet, with initial data obtained from
hashFunction(value, rawValue) defines how the identity of objects is determined.
value is the evaluated value, which might be the contents of another
observ or a computed function.
rawValue is whatever is passed to
ObservSet. Note that
hashFunction should return a primitive value, in most cases, if values are to be compared properly. Can also be called without the
Observ interface. Returns a copy of the values in the set, as an array.
Observ interface. Calls
onChange(values) with a copy of the values contained in the set, as an array.
Observ interface. Applies the
array and overwrites the set with the new values, notifying all listeners.
value and adds the value if in the set, notifying all listeners if a value was added.
Clears the set and notifies all listeners.
value and deletes the value if in the set, notifying all listeners if a value was deleted.
Returns an iterator with
[value, value] entries, from a copy of the values contained in the set.
Starts a transaction around
callback(value, value, rawSet), allowing you to modify
rawSet and notify all listeners if any changes are made.
value and returns a Boolean whether the values is contained in the set.
Returns an iterator from a copy of the values contained in the set.
callback(rawSet) is passed a Set-like object that you can safely mutate without notifying listeners before the transaction is over. If no mutations are made, the listeners will not be notified. Transactions can be canceled by returning