feat(atoms): dedupe mapped signal events that reach multiple children #221
+79
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
MappedSignal#set
currently handles the case where a single call causes updates in multiple inner signals. It also filters down which events to pass to each inner signal.MappedSignal#send
is missing these features - when an event is sent directly to the wrapping signal that reaches multiple inner signals, each inner signal will propagate the event again, back up to the mapped signal and its observers.MappedSignal#send
also does not support the object overload ofSignal#send
even though the types suggest it does.Fix those cases. Make
MappedSignal#send
handle the object overload. Make it only propagate each event to its own observers once. Also give mapped signals the ability to specify their own events. Add tests for all of that.