-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vitaliy Berekchiyan
committed
Nov 18, 2023
1 parent
cb7a955
commit 3e71399
Showing
43 changed files
with
427 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,4 @@ | |
], | ||
"repository": "https://github.com/vitlolik/svitore", | ||
"license": "MIT" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { describe, it, expect, vi } from "vitest"; | ||
|
||
import { Event } from "./event"; | ||
import { Entity } from "./services"; | ||
|
||
describe("event", () => { | ||
it("type", () => { | ||
const event = new Event(); | ||
|
||
expect(event).instanceOf(Entity); | ||
}); | ||
|
||
describe("dispatch - call event with payload", () => { | ||
it("should notify subscribers", () => { | ||
const event = new Event<number>(); | ||
const subscriber = vi.fn(); | ||
event.subscribe(subscriber); | ||
|
||
expect(subscriber).toBeCalledTimes(0); | ||
|
||
event.dispatch(1); | ||
expect(subscriber).toBeCalledTimes(1); | ||
expect(subscriber).toHaveBeenCalledWith(1, event); | ||
|
||
event.dispatch(2); | ||
expect(subscriber).toBeCalledTimes(2); | ||
expect(subscriber).toHaveBeenCalledWith(2, event); | ||
|
||
event.dispatch(0); | ||
expect(subscriber).toBeCalledTimes(3); | ||
expect(subscriber).toHaveBeenCalledWith(0, event); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AbstractEvent } from "./services"; | ||
|
||
class Event<Payload = void> extends AbstractEvent<Payload> {} | ||
|
||
export { Event }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export { State } from "./state"; | ||
export { ComputedState } from "./computed-state"; | ||
export { PersistState } from "./persist-state"; | ||
export { Event } from "./event"; | ||
export { DebouncedEvent } from "./debounced-event"; | ||
export { ThrottledEvent } from "./throttled-event"; | ||
export { Effect } from "./effect"; | ||
export { Reaction } from "./reaction"; | ||
|
||
export type { EffectFunction } from "./effect"; | ||
export type { Middleware } from "./services"; |
Oops, something went wrong.