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

Introduce compose, remove extend #192

Closed
mweststrate opened this issue Jun 15, 2017 · 4 comments
Closed

Introduce compose, remove extend #192

mweststrate opened this issue Jun 15, 2017 · 4 comments
Assignees

Comments

@mweststrate
Copy link
Member

Replaces extend, which is to be removed.

Proposed api:
const NewModel = types.compose(BaseModel, newProps, newActions)

  1. Note that this does not establish an inheritance relationship; it just takes the defiinition on BaseModels and constructs a new model form it.
  2. reconfiguring props is not allowed
  3. reconfiguring actions is allowed.
  4. "Supercalls" can be made by using BaseModel.actions.actionName.call(this, args)
  5. baseModel.isAssignableFrom(NewModel) will yield false. If you need a place where both types are allowed, use union(NewModel, BaseModel)
@mweststrate mweststrate added this to the 1.0 - initial release milestone Jun 15, 2017
@RainerAtSpirit
Copy link
Contributor

How would computeds be handled in with this proposed API?

@mweststrate
Copy link
Member Author

Good question. I think newProps should allopw overriding computeds from BaseModel

@mweststrate
Copy link
Member Author

reusing computed from "super" if overriding will probably be tricky though, that requires a helper function

@mweststrate mweststrate self-assigned this Jun 16, 2017
robinfehr pushed a commit to robinfehr/mobx-state-tree that referenced this issue Jun 17, 2017
robinfehr pushed a commit to robinfehr/mobx-state-tree that referenced this issue Jun 17, 2017
mweststrate added a commit that referenced this issue Jun 19, 2017
Basic compose implementation, see #192
@mweststrate
Copy link
Member Author

Released as 0.8.0

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

3 participants