-
Notifications
You must be signed in to change notification settings - Fork 638
add parent to preProcessor and postProcessor #2065
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
add parent to preProcessor and postProcessor #2065
Conversation
|
Looks great, thanks @BrianHung! I'm gonna merge this in. Might end up just wrapping it up in a new candidate for 5.2.0 this weekend. |
|
The posted example above doesn't work as is https://codesandbox.io/s/mobx-state-tree-pr-2065-8kj95v |
|
@chakrihacker - you have that pinned to |
|
In Mobx State Tree when you mark something as required, you validate before creating that instance, something like this https://codesandbox.io/s/mobx-state-tree-pr-2065-with-working-8f3qgp?file=/src/index.js I don't see any use case here too |
|
@chakrihacker - two questions for you:
My philosophy when merging this is that it's a small change with a totally opt-in feature, and I know Brian has a lot of advanced use cases that I want to support in the main MST releases. I don't think this PR impacts stability or performance, so I was happy to give him some nicer utilities than we previously had. |
The problem is not about the master, you cannot just directly push to the array, without actions |
|
Calculating parent is definitely a performance issue. The problem is this doesn't contain proper test cases and documentation and yet it's merged. |
|
I am not against new features here, I am just trying to help and validate that my most loving state management library is working properly. |
|
@chakrihacker - the missing test cases and documentation is a fair point. My approach here was to be grateful for Brian's work as is, since the change was small and I know he's wanted things like this in the past. I was hoping to keep things moving and extend functionality for a heavy user in a small way. Perhaps I moved a little too quickly here. However, this is precisely the reason I wanted to start with an alpha build for Here's my proposal for how to resolve this:
In the meantime, we'll hold off on In parallel, we should consider updating our contributing guidelines. We don't currently have a set of rules about what PRs can and can't be merged, so it's up to individual judgment. In this case, I perhaps made a poor judgment call. I'd be happy to take a draft set of contribution guidelines from you, or input from you as well. My plan would be to start with a similar set library's guidelines. All that to say, thanks for the feedback, and apologies for the misstep here. We will figure out a path forward! |
|
Thanks @coolsoftwaretyler |
This PR gives
preProcessorandpostProcessoraccess to the parent context.This is useful when the incoming / outgoing snapshot should depend on parent state. For example, let's say we have an array of objects that each have a name and a type. When
snapshot.name === null || snapshot.name === "", we want to use${type} ${number of types in array + 1}$.With access to the parent context in
preProcessor, we can do this easily!