Skip to content

What code can you run inside effect transactions? #60

Closed Answered by GregoryConrad
busslina asked this question in Q&A
Discussion options

You must be logged in to vote

I mean code that can conditionally call a setter function.

Yes. Don't run anything that can throw an exception though--that is not supported ATM.

container.read, container.runTransaction, and side effect rebuilds are all fair game. Just be a little careful that the data that you container.read is actually immutable; i.e., imagine the following:

container.runTransaction(() {
  final (_, setState) = container.read(someStateGetterSetterCapsule);
  setState(1234);
  final (getState, _) = container.read(someStateGetterSetterCapsule);
  // invoking getState here will return 1234, despite the rebuild not happening until later!
);

This is another one of those issues that isn't an issue in Rust.…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GregoryConrad
Comment options

Answer selected by GregoryConrad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants