-
Notifications
You must be signed in to change notification settings - Fork 535
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(tree): Include list of properties that changed in nodeChanged event #22043
Conversation
🦋 Changeset detectedLatest commit: 135659d The changes in this PR will be included in the next version bump. This PR includes changesets to release 157 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Successfully linked to Azure Boards work item(s): |
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.
Please add a changeset.
⯅ @fluid-example/bundle-size-tests: +1.56 KB
Baseline commit: 06f2989 |
Do we plan to generalize this to apply to treeChanged in the future? I could see the same functionality being great there as well. That also makes me thing: I don't think this includes a test where we change a node deeper in the tree (ex: a child) and make sure the parent doesn't get a nodeChanged, of when it does, keys inly deeply edited don't get included in the changed key list (like they would be in treeChanged). Anyway, the parts I looked at (API, changeset and tests) generally look good to me, though I left some suggestions. |
@@ -390,7 +390,9 @@ export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAl | |||
|
|||
// @public @sealed | |||
export interface TreeChangeEvents { | |||
nodeChanged(): void; | |||
nodeChanged({ changedProperties }: { | |||
changedProperties: ReadonlySet<string>; |
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 a little concerned about forward compat (for when we finally expose information about what the changes were).
Is there a design for what that will look like?
Are we expecting to just deprecate changedProperties
and use another key for the future API? (propertyChanges
?)
Or would we be better off exposing changedProperties: ReadonlyMap<string, unknown>
for now, so we can fill in the blanks 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.
I think the fact that changedProperties
is inside of a property bag {...}
(as opposed to directly being the first parameter to the event) is sufficient for future-proofing and about as good of a guess as we can make. To add more information in the future, we don't need to break the event signature, we just add more properties to the event bag. Maybe there's some overlap with the existing properties and a new property supersedes an old one, but that's fine, the user can just ignore the deprecated one.
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 cool with that so long as we're going into it with our eyes open.
Feel free to resolve this comment without further changes.
Dismissing since there's a changeset now. Haven't reviewed it yet but don't block on me.
*/ | ||
export function getViewForForkedBranch<TSchema extends ImplicitFieldSchema>( | ||
originalView: SchematizingSimpleTreeView<TSchema>, | ||
): { forkView: SchematizingSimpleTreeView<TSchema>; forkCheckout: ITreeCheckoutFork } { |
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.
Should we define a type for this? That would give us a better place to document it properties and such.
nodeChanged(): void; | ||
nodeChanged({ | ||
changedProperties, | ||
}: { readonly changedProperties: ReadonlySet<string> }): void; |
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.
Should we define a type for this?
I created #22229 which merges main into this and fixed up a few things. |
…g. (#22222) ## Description See changeset for details. This will be used for things like providing object node specific events with strong typing. This is aimed to provide the functionality attempted in alexvy86#7 to better support node kind specific data in #22043
Description
This adds a payload to the
nodeChanged
event in simple-tree, where we specify the names of the properties of the node that changed and caused the event to fire.TODO (in this PR)
Reviewer Guidance
The review process is outlined on this wiki page.
AB#8399