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

Support init or setup returning something other than new instance ~13 #2

Closed
justinbmeyer opened this issue May 15, 2016 · 2 comments
Closed
Assignees

Comments

@justinbmeyer
Copy link
Contributor

For canjs/canjs#721 it would be nice to make it possible for the constructor to return something other than the new instance. This is useful for singleton type setups.

@justinbmeyer justinbmeyer added this to the 3.0.0 milestone May 15, 2016
@justinbmeyer justinbmeyer removed this from the 3.0.0 milestone Oct 17, 2016
@justinbmeyer justinbmeyer changed the title Support init or setup returning something other than new instance Support init or setup returning something other than new instance ~13 Oct 17, 2016
@justinbmeyer
Copy link
Contributor Author

Somehow, we'd need a way to allow setup, or some other function, to return a value other than the instance being created.

Hub.extend({
  setup: function(){
    if(IN INSTANCE STORE){
      // somehow signal to return the instance in the store instead of `this`
    }
  }
})

Setup can return an array which will be used as the arguments to init. Perhaps it can return some other flag like new Construct.ReturnValue( somethingElse ) ... which can be used as the return value from the constructor

@ilyavf ilyavf self-assigned this Jan 24, 2017
@ilyavf
Copy link
Contributor

ilyavf commented Jan 26, 2017

This is fixed with #30

@ilyavf ilyavf closed this as completed Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants