Skip to content

Commit

Permalink
Trigger on update whenever a component is updated (#918)
Browse files Browse the repository at this point in the history
* trigger on update whenever a component is updated

* update doc
  • Loading branch information
maxence-charriere committed Jan 15, 2024
1 parent 200b16d commit 424c7c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 4 additions & 5 deletions pkg/app/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ type Navigator interface {
}

// Updater encapsulates components that require specific behaviors or reactions
// when one of their exported fields is updated by the closest parent component.
// when it is updated.
// Implementing the Updater interface allows components to define responsive
// actions that should be executed whenever they are modified by a parent.
// actions that should be executed whenever they are modified.
type Updater interface {
// OnUpdate is triggered whenever an exported field of the component gets
// modified by its immediate parent component. This method is an opportunity
// to handle related reactions or recalculations.
// OnUpdate is triggered whenever the component is updated. This method is
// an opportunity to handle related reactions or recalculations.
// This function always runs within the UI goroutine context.
OnUpdate(Context)
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/app/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,6 @@ func (m nodeManager) updateComponent(ctx Context, v, new Composer) (UI, error) {
return v, nil
}

// if updater, ok := v.(Updater); ok {
// updater.OnUpdate(ctx)
// }

ctx.removeComponentUpdate(v)
return m.UpdateComponentRoot(ctx, v)
}
Expand Down

0 comments on commit 424c7c1

Please sign in to comment.