Skip to content

Instantly share code, notes, and snippets.

@publickeating
publickeating / custom_view_with_internal_statechart.js
Last active December 13, 2015 17:19
A custom view that manages its state using SC.StatechartManager instead of internal flags. This is a simple view that only needs to toggle an active property when the mouse is over it. However, as simple as this requirement is, we can see that it benefits from using a statechart because the isEnabled value affects the behaviour. Imagine if there…
/**
* A view that adds an 'active' class when the mouse is over it.
*/
MyApp.MyView = SC.View.extend(SC.StatechartManager, {
/** @private */
displayProperties: ['isActive', 'isEnabled'],
/**
Whether the view is active or not.