Skip to content

Commit

Permalink
ability to specify custom watch intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
radek00 committed Oct 29, 2024
1 parent 450b40c commit c07f6a5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Transport/@stateflows/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stateflows/common",
"version": "0.13.0",
"version": "0.14.0",
"description": "Common package for Stateflows framework clients",
"main": "dist/index.js",
"module": "./dist/index.mjs",
Expand Down
4 changes: 2 additions & 2 deletions Transport/@stateflows/common/src/behaviors/behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export class Behavior implements IBehavior, IWatcher {
}
}

async watch<TNotification extends Notification>(notificationName: string, handler: NotificationHandler<TNotification>): Promise<void> {
async watch<TNotification extends Notification>(notificationName: string, handler: NotificationHandler<TNotification>, interval = 10 * 1000): Promise<void> {
let transport = await this.#transportPromise;
await transport.watch(this, notificationName);
await transport.watch(this, notificationName, interval);

let handlers: Array<NotificationHandler<Notification>> = this.#notificationHandlers.has(notificationName)
? this.#notificationHandlers.get(notificationName) as Array<NotificationHandler<Notification>>
Expand Down
2 changes: 1 addition & 1 deletion Transport/@stateflows/common/src/interfaces/behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface IBehavior {
finalize(): Promise<RequestResult<FinalizationResponse>>;
reset(resetMode?: ResetMode): Promise<RequestResult<ResetResponse>>;

watch<TNotification extends Notification>(notificationName: string, handler: NotificationHandler<TNotification>): Promise<void>;
watch<TNotification extends Notification>(notificationName: string, handler: NotificationHandler<TNotification>, interval?: number): Promise<void>;
unwatch(notificationName: string): Promise<void>;

getStatus(): Promise<RequestResult<BehaviorStatusResponse>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { IWatcher } from "./watcher";
export interface IStateflowsClientTransport {
getAvailableClasses(): Promise<BehaviorClass[]>;
send(behaviorId: BehaviorId, event: Event): Promise<SendResult>;
watch(watcher: IWatcher, notificationName: string): Promise<void>;
watch(watcher: IWatcher, notificationName: string, interval: number): Promise<void>;
unwatch(watcher: IWatcher, notificationName: string): Promise<void>;
}

0 comments on commit c07f6a5

Please sign in to comment.