-
Notifications
You must be signed in to change notification settings - Fork 33
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
Feat/emit initial value on init #296
Open
ophirKatz
wants to merge
6
commits into
cloudnc:master
Choose a base branch
from
ophirKatz:feat/emitInitialValueOnInit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
567005f
added emitInitialValue
ophirKatz 3289515
Added emitInitialValueOnInit feature, works on example
ophirKatz f631ce4
Removed unnecessary demo code, need to add tests
ophirKatz 0539c3e
Updated README file to include documentation on emitInitialValueOnIni…
ophirKatz 4b97f08
ran prettier linter
ophirKatz d451c51
testing broadcastDefaultValue
ophirKatz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would have an influence on the rest of the emissions, not only the initial one. I wonder if we'd be better off having an option to exclude the isEqual check, or maybe even customise it entirely 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was thinking here is that it's good that it will affect all emissions because if (and only if) the initial value of the form (let's name it V) is valid, then I would want to emit it on init, and then if it would change to V overtime, it's still a valid value. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think then it's not the correct name for the option as it's misleading on what is going to happen while using it.
When I see an option that finishes by
onInit
I assume it's going to change a behavior only on init, not for the rest of the lifecycle.This sounds more like a variable that should be named
skipEqualCheck
or something similar (don't really like the one I'm mentioning here but hopefully you get the idea).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I get that, but for me I think it's a side effect of what I'm trying to achieve - emitting the default values. I've been thinking that it should be named that, maybe - emitDefaultValues, but that still doesn't resonate with the side effect of skipping the equals check. But what do you think about it regardless of naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is a good idea, the reason being that every time one of the sub form will "connect" to the root form, it'll try to emit.
So if you've got a root form with
subForm1
,subForm2
,subForm3
, and each of them have 3 sub forms as well, you'd get 1 (root form init) + 3 (the direct sub forms) + 3*3 (sub sub forms) = 13 events out of the root form. Which doesn't sound ideal to me tbh. And it's probably the main reason we left that as it is today, because we didn't see an easy fix. I'm not saying it's impossible, but I suspect the approach you've taken here may not be enough to be taken as is. When a form changes, especially a root form, it can trigger side effects (network calls, large computations etc) and I don't think that emitting multiple times is reasonable.Now, I know it wouldn't be by default and this is an option BUT, the option idea is to emit the initial value. Except that when using it, so much more would be happening and changing the default behavior a lot more than just emitting the initial value.
The issue being, there's no easy way to know when all the form/sub forms have been properly initialized. Maybe we could go around that using DI and declare a token on a root form and then each sub form would register itself along the way? But that's a lot more work and questions