Comments (2)
This should give a rough idea:
The referenceTo
is interesting; it creates a normal string property in which the identifier is stored, and a setter and computed getter to resolve the identifier with the provided path.
Note that you don't have to resolve via strings, you can also introduce a computed property yourself, and write something like:
selectionId: '123'
get selection() {
if (hasParent(this))
return getParent(this).boxes.get(this.selectionId)
return null
}
Resolving a list of identifiers is still on the todo list, but will be part of the first version :)
Sorry for not having docs yet, they will be added, but ATM this is quite alpha :)
from mobx-state-tree.
I'm kind of lost :)
I understand it's alpha, no worries. With the risk of sounding silly, what's the benefit of using mobx-state-tree
?
Or more specifically isn't there a away to do the same thing without mobx-state-tree
? Looking at the example you linked above to me hasParent()
and getParent()
look evil. Why isn't parent just a property instead of magically inferred from outside? Also selection
looks like it's better if it's a @computed
property based on any box that has isSelected
property equal true
.
Moreover referenceTo
or resolve
use some sort of string-based identifier. This all looks very odd to me. It's kind of query language like xpath. Is it an official thing? Otherwise why introduce a new one?
As you mentioned - using getters and setters is enough to do resolving logic. It is also as custom as a person like. Why not stop there?
Wouldn't it be better if mobx-state-tree
just takes care of getSnapshot
and applySnapshot
by requiring the developer to create stores that implement a specific interface?
from mobx-state-tree.
Related Issues (20)
- RootStore type becomes "any" the moment we call a RootStore model action using yield on a child model action HOT 3
- Unintended behavior when creating new models with falsy first argument HOT 8
- detach can corrupt the identifierCache HOT 2
- Add tests and documentation for debug names in complex types
- Add tests and documentation for new parent argument to `types.optional` HOT 1
- Document how MST lazily creates objects HOT 1
- Use getTime() to check for Date equality HOT 8
- Remove Lerna config and lift MST sub-package up
- When observe() a MST node's primitive property, TypeScript get the wrong type of oldValue & newValue HOT 1
- Add safeMap utility (or something like it)
- Broken Map type in 5.3.0 HOT 8
- TypeError: 0, _mobx.defineProperty is not a function (it is undefined) HOT 4
- applySnapshot is slow HOT 1
- Unexpected error "Сannot finalize the creation of a node that is already dead" while applying snapshot HOT 16
- Linters do not recognize `fail` as a required import in library code HOT 4
- REST - create data with server side ID HOT 2
- Better documentation on action/view definitions and their impact on IDE introspection, navigation and refactoring HOT 2
- Missing docs for `types.lazy` HOT 2
- getMembers does not work as expected, behaviour change between 5.1.0 and 5.4.1 HOT 11
- Model constructor modifies descriptor object HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobx-state-tree.