Skip to content

Commit

Permalink
fixed release methods, fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Berekchiyan committed Dec 4, 2023
1 parent f701e85 commit 07cd405
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 150 deletions.
7 changes: 1 addition & 6 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ export default defineConfig({
title: "Svitore",
description: "State manager",
themeConfig: {
nav: [
{ text: "Home", link: "/" },
{ text: "Examples", link: "/markdown-examples" },
],
nav: [{ text: "Home", link: "/" }],

sidebar: [
{ text: "Get Started", link: "/getting-started" },
{ text: "Markdown Examples", link: "/markdown-examples" },
{ text: "Runtime API Examples", link: "/api-examples" },
{
text: "Entities",
items: [
Expand Down
55 changes: 0 additions & 55 deletions docs/api-examples.md

This file was deleted.

85 changes: 0 additions & 85 deletions docs/markdown-examples.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/entities/effect-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ class EffectRunner<
}

release(): void {
this.stop();
this.pending.release();
this.changed.release();
super.release();
this.stop();
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/entities/services/abstract-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ abstract class AbstractEvent<Payload = void> extends Entity<Payload> {
this.dispatch(selector ? selector(payload) : payload);
});
}

release(): void {
this.middlewares = [];
super.release();
}
}

export { AbstractEvent };
Expand Down
1 change: 1 addition & 0 deletions src/entities/services/delayed-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class DelayedEvent<Payload = void> extends AbstractEvent<Payload> {
}

release(): void {
this.pending = false;
this.clearTimer();
super.release();
}
Expand Down
8 changes: 5 additions & 3 deletions src/entities/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ class State<Data> extends AbstractState<Data> {
changeOn<Payload extends Data>(event: Event<Payload>): this;
changeOn<Payload>(
event: Event<Payload>,
selector: (payload: Payload, state: Data) => Data
selector: (payload: Payload, state: Data, prevState: Data) => Data
): this;
changeOn(
event: Event<any>,
selector?: (payload: any, state: Data) => Data
selector?: (payload: any, state: Data, prevState: Data) => Data
): this {
return this.trigger(event, (payload) => {
this.notify(selector ? selector(payload, this.get()) : payload);
this.notify(
selector ? selector(payload, this.get(), this.getPrev()) : payload
);
});
}

Expand Down

0 comments on commit 07cd405

Please sign in to comment.