Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Statechart stateObserves() never stops firing with a property path containing @each #607

Closed
jcgatica opened this Issue Sep 27, 2011 · 2 comments

Comments

Projects
None yet
3 participants

When in a state that uses stateObserves, the events get sent properly, but if the observed property path contains @each, the event continues to fire even if the state has been exited. Below is a sample state chart that pays attention to an array controller that manages a collection of objects with an "isEnabled" property. Unfortunately, the objectStateChanged() event fires even if the state chart transitioned from "cleanState" to "dirtyState". Perhaps an issue with the underlying addObserver/removeObserver?

Test.stateChart = SC.Object.create(SC.StatechartManager,
{
    autoInitStatechart:NO,

    rootState: SC.State.extend(
    {
        initialSubstate: "cleanState",

        cleanState: SC.State.extend(
        {
            editedObjectsController: null,
            editedObjectsControllerBinding: "Test.modelArrayController",

            enterState: function()
            {
                SC.Logger.log("in clean state");
            },

            objectCheckStateChanged: function() 
            {
                SC.Logger.log("An object was selected");
                this.gotoState("dirtyState");
                return YES;
            }.stateObserves(".editedObjectsController*arrangedObjects.@each.isEnabled")
        }),

        dirtyState: SC.State.extend(
        {
            enterState: function()
            {
                SC.Logger.log("Entered dirtyState");
            }
        })
    })
});
Member

FrozenCanuck commented Sep 28, 2011

Interesting. I'm looking into this.

Owner

publickeating commented Apr 30, 2014

I built this exact example and found that this is no longer an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment