You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.
Thanks man! I've got you covered! You need to use computed values:
state=newStatesman({todos: todos});state.compute('completed_todos',{trigger: 'todos',fn: function(todos){returntodos.filter(function(t){returnt.completed;})}});state.observe('completed_todos.length',function(num){alert(num+' todos completed');},true);// passing in true here means it fires straight away rather than waiting for a change
I thought about doing some kind of wildcard/regex-based observers, but eventually decided against it because it would mean that whenever any part of the model changed, all the wildcard patterns would need to be tested (as opposed to just doing property lookups, as at present) which could get slow with a complex model. All of the things I could think of wanting to do with wildcards can be done with computed values, and I believe it's more efficient that way.
I hadn't seen dotty, will check it out, cheers.
Yeah, this is a better tool for overall state management than Anglebars - an Anglebars instance is only really concerned with its own state, whereas this is designed to be central to an app. Of course, you can bind the two together with e.g.
Rich!! You got some goodies in here!! Statesman is awesome as hell!, gonna use this one instead! :-)
Feature request! (which plays well with Anglebars)
It would be GREAT if something like the following was possible:
(the above can obviously be achieved as well by setting an observer on every single item)
Check this out: https://github.com/deoxxa/dotty/blob/master/lib/index.js
:-)
The text was updated successfully, but these errors were encountered: