Skip to content

Commit

Permalink
✨Supported specifying refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
carefree0910 committed Nov 5, 2024
1 parent aa2ef74 commit acad202
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion cfb-core/src/world/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ export class AutoRefreshWorld<
*
* @param alias The alias of the node.
* @param dirtyStatus The dirty status to be set.
* @param refresh Whether to refresh the renderer instantly after setting dirty status.
* > This is useful for UI rendering, because UI elements are expected to have a
* > instant response to the user's interactions.
*/
setDirtyStatus(alias: string, dirtyStatus: DirtyStatus): void {
setDirtyStatus(alias: string, dirtyStatus: DirtyStatus, refresh?: boolean): void {
this.getBNode(alias).setDirtyStatus(dirtyStatus);
if (refresh) {
this.renderer.refresh();
}
}
/**
* Get the plugin by its type.
Expand Down
5 changes: 4 additions & 1 deletion cfb-core/src/world/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ export interface IWorld<
*
* @param alias The alias of the node.
* @param dirtyStatus The dirty status to be set.
* @param refresh Whether to refresh the renderer instantly after setting dirty status.
* > This is useful for UI rendering, because UI elements are expected to have a
* > instant response to the user's interactions.
*/
setDirtyStatus(alias: string, dirtyStatus: DirtyStatus): void;
setDirtyStatus(alias: string, dirtyStatus: DirtyStatus, refresh?: boolean): void;
/**
* Get the plugin by its type.
*
Expand Down
5 changes: 2 additions & 3 deletions cfb-web/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ function setFill(
const fillParams = node.params.fillParamsList![0] as ISolidFillParams;
fillParams.color = color;
fillParams.opacity = opacity;
world.setDirtyStatus(node.alias, DirtyStatus.CONTENT_DIRTY);
// trigger a refresh manually for instant feedback
world.renderer.refresh();
// trigger refresh for instant feedback
world.setDirtyStatus(node.alias, DirtyStatus.CONTENT_DIRTY, true);
return Promise.resolve();
}

Expand Down

0 comments on commit acad202

Please sign in to comment.