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

doc: Improve description of action and transaction (#3017) #3018

Merged
merged 4 commits into from
Jul 29, 2021

Conversation

jheeffer
Copy link
Contributor

Closer description of actual implementation.

Closer description of actual implementation.
@changeset-bot
Copy link

changeset-bot bot commented Jun 29, 2021

⚠️ No Changeset found

Latest commit: 711d35d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

docs/actions.md Outdated
@@ -18,7 +18,7 @@ All applications have actions. An action is any piece of code that modifies the

MobX requires that you declare your actions, although [`makeAutoObservable`](observable-state.md#makeautoobservable) can automate much of this job. Actions help you structure your code better and offer the following performance benefits:

1. They are run inside [transactions](api.md#transaction). No observers will be updated until the outer-most action has finished, guaranteeing that intermediate or incomplete values produced during an action are not visible to the rest of the application until the action has completed.
1. They are run inside [transactions](api.md#transaction). No reactions will be run until the outer-most action has finished, guaranteeing that intermediate or incomplete values produced during an action are not visible to the rest of the application until the action has completed. However, computeds will update when they have become stale and are read during an action.
Copy link
Collaborator

@urugator urugator Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, computeds will update when they have become stale and are read during an action.

I don't think it makes sense to mention computed here as some special case. It behaves the same as any observable value in regards to transactions. It always yields most up to date value, (trans)action or not. It is a computed value in the end.

Perhaps if necessary, something like:
"Observable values (including computeds) are unaffected by action and always yield current value."
??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, it was more to contrast computed from reaction as an observer, but that was due to the previous text mentioning observers. Since that is gone, indeed no need to have computed here at all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to elaborate a bit and perhaps justify the original wording a little...
From user's perspective the library conceptually consists of two parts: consumers (observers) and consumables (observables).
Computed is part of the consumable part (observable). While computed is internally "observer", it can't be used alone to consume observables.
Action is only relevant for the consuming part (observers) - reaction/autorun/observer.
Unfortunatelly neither the implementation or API maps to this natural division very well.
The most precise word to use here, would be Reaction (with capital R), which is internally used to implement all consumers (observers) - however since it's just an internal concept, nobody would understand that either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, yeah, building a consistent & coherent DSL is hard, especially if it happens incrementally, I feel ya : )

@urugator urugator merged commit decb563 into mobxjs:main Jul 29, 2021
urugator pushed a commit to urugator/mobx that referenced this pull request Oct 13, 2021
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.

3 participants