Skip to content

Conversation

@k-g-a
Copy link
Member

@k-g-a k-g-a commented Aug 8, 2018

This PR is purely internal.
Basically it replaces createNewInstance + finalizeNewInstance combo with just one initializeInstance call.
Another step to make code cleaner was to remove createNewInstance/finalizeNewInstance from createNode's arguments, as those were taken from type anyway (inside type.instantiate). As we have type inside ObjectNode/ScalarNode there is not need to pass those two methods 3 calls deep separately.
As a side effect this makes createNode and Node's constructor's calls less polymorphic and slightly reduces subsequent calls time.

@k-g-a
Copy link
Member Author

k-g-a commented Aug 9, 2018

Ok, had to split create/finalize back, because ModelType's finalize calls hooks, which in turn want $treenode to be attached to self... Well, it got too complex.
This PR is basically a cleanup for createNode and related codepaths now.

@k-g-a k-g-a changed the title Simplify observable instance creation [Internal] Cleanup 'createNode' and related codepaths Aug 9, 2018
@k-g-a
Copy link
Member Author

k-g-a commented Aug 9, 2018

I advice merging #959 first - it will conflict with this one.

@mweststrate
Copy link
Member

@k-g-a could you rebase this branch and see what remains?

@k-g-a
Copy link
Member Author

k-g-a commented Aug 10, 2018

@mweststrate, sure. I’ll have a look at Monday

# Conflicts:
#	packages/mobx-state-tree/src/core/node/object-node.ts
#	packages/mobx-state-tree/src/core/node/scalar-node.ts
#	packages/mobx-state-tree/src/types/complex-types/model.ts
@mweststrate mweststrate merged commit 7dc4e3a into master Aug 17, 2018
@xaviergonz xaviergonz deleted the simplify-instance-creation branch November 25, 2018 11:34
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

Successfully merging this pull request may close these issues.

4 participants