- added
unwatch
- improve
Cache
types
- fixed Circular dependency
- added
createEvent
andonDestroy
utils - deprecated
onDestroy
ofWatch
andCache
, useonClear
- added new tests and jsDoc comments
- refactor structure
- added
size
field ofCache
which returns count of subscribers
- fixed bug of deep event using, in watcher and during another event
- fixed types of
scope
, addedScope
type - removed all default exports
- fixed bug of
globalEvent
- added
scope
export
- updated readme
Stable version
- normalized watchers running flow
- fixed deep bugs
- added
globalEvent
- unfortunately, the performance has decreased, but the current version is strong stable and still, this is one of the fastest solutions.
- fixed deep unwatched cache updating bag
const state = new State(0)
const cache1 = new Cache(() => state.value)
const cache2 = new Cache(() => cache1.value)
console.log(cache2.value) //0
state.value = 1
console.log(cache2.value) //1 (before: 0)
- fixed infinite loop bug when you change that value you watch
const count = new State(0)
new Watch(() => {
if (count.value < 2) {
console.log(count.value++)
}
})
// now you have `1` and `0` in console, before it was infinite loop
- fixed readme icons
- fixed bug when you change and ask cache value inside an event
const event = new Event()
const state = new State(1)
const cache = new Cache(() => state.value)
console.log(cache.value)
// 1
event.start()
state.value = 2
console.log(cache.value)
// 2 (before: 1)
event.end()
- decreased weight
- increased performance
Now watch-state faster than redux in complex case
- fixed misprint bug of previous release
- improved using of
events
inside awatcher
- fixed a bug relates to the previous release
- fixed a bug relates to the previous release
- now
events
ignore watching, so you can use them inside watchers.
- fixed empty event running bug
- fixed circular dependency bug
- fixed a bug of importing
- removed baseUrl using
- updated readme
Now, update
method of Cache
do not update it immediately, only if you use cache value inside a watcher.
- reduced utils, use @watch-state/utils
- reduced decorators, use @watch-state/decorators
- changed
destructor
todestroy
- added
Event
class - deep refactoring
To migrate from the first version please:
- update to
2.0.0-migration
- fix all errors in the browser console or fix all deprecated functionality
- update to the second version
- reduced code
- removed cache decorator using with methods
- removed deprecated code
- reduced code
- deprecated mixer
- added
getState
andgetCache
- fixed a bug when a state in a cache in a watcher in a watcher which uses the state.
const log = []
const state = new State(1)
const cache = new Cache(() => state.value + 1)
new Watch(() => {
if (state.value) {
new Watch(() => log.push(cache.value))
}
})
expect(log).toEqual([2])
state.value = 0
expect(log).toEqual([2]) // was [2, 1]
- added
getDecor
andgetDecors
- deprecated
stateValues
- fixed loop bug
- fixed
mixer
bugs
- removed watching in event
- fixed an exception error
- small improvements
- fixed cache in cache bug