Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proble with stack overflow in recursive children #181

Open
weepy opened this issue Jul 16, 2015 · 2 comments
Open

proble with stack overflow in recursive children #181

weepy opened this issue Jul 16, 2015 · 2 comments

Comments

@weepy
Copy link

weepy commented Jul 16, 2015

Hi I'm trying to model a (multiply) nested object using children

I get a stack overflow with :

var M = State.extend({    
    children: {
        inner: function(x) {
            // x
            if( !isEmpty(x) ) {
                return new M()
            }
            return new End() // end
        }
    }
});

var m = new M({ inner: { stuff: true } });

Any ideas how to do this ?

weepy added a commit to weepy/ampersand-state that referenced this issue Jul 16, 2015
This simply sends the attrs to _initChildren, so that derived models can override _initChildren and reason about the passed in attrs. See AmpersandJS#181.
@kamilogorek
Copy link
Contributor

Could you post requirebin gist with your code?

I'm not sure whether you checked, but inner function will get empty object here, as children object expect key: value pair, where value is a state/model constructor.

@weepy
Copy link
Author

weepy commented Jul 22, 2015

You're right that's exactly what happens, so it means I can't have polymorphic children.

My pull request simply does this._initChildren(attrs, options); in the constructor so that I can override _initChildren in my derived class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants