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
dzearing edited this page Oct 14, 2014
·
2 revisions
Summary
The Observable class provides a simple wrapper with two methods, setValue and getValue, and fires a change event when the value changes.
When dealing with literals, there is no "object" that can be passed around to represent the value, and as such changing the value can't easily be reflected in more than one place.
To compensate, we can wrap shared literal values in an Observable class within a ViewModel. This gives the ViewModel something to observe, allowing it to notify the View when the value changes.
When the toggle button wants to change its "isToggled" state, the observable is detected, setValue is called, a change event fires, and FooModel can update the div's text to the boolean state.