-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PubSub for Redis and SingleProcess; refactor ComponentManager, Ba…
…seLiveViewComponent, and MessageRouter to use PubSub; refactor examples based on PubSub and PushPatch api change
- Loading branch information
Showing
16 changed files
with
672 additions
and
641 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,34 +1,13 @@ | ||
import { SessionData } from "express-session"; | ||
import { LiveViewComponent, LiveViewMountParams, LiveViewSocket, LiveViewTemplate, StringPropertyValues } from "./types"; | ||
import { LiveViewComponentManager } from "../socket/component_manager"; | ||
|
||
export abstract class BaseLiveViewComponent<T, P> implements LiveViewComponent<T, P> { | ||
|
||
private componentManager: LiveViewComponentManager; | ||
|
||
abstract mount(params: LiveViewMountParams, session: Partial<SessionData>, socket: LiveViewSocket<T>): T | Promise<T>; | ||
abstract render(context: T): LiveViewTemplate; | ||
|
||
handleParams(params: StringPropertyValues<P>, url: string, socket: LiveViewSocket<T>): T | Promise<T> { | ||
return socket.context; | ||
} | ||
|
||
pushPatch(socket: LiveViewSocket<unknown>, patch: { to: { path: string, params: StringPropertyValues<any> } }) { | ||
if (this.componentManager) { | ||
this.componentManager.onPushPatch(socket, patch); | ||
} else { | ||
console.error("component manager not registered for component", this); | ||
} | ||
} | ||
|
||
csrfToken(): string | undefined { | ||
if (this.componentManager) { | ||
return this.componentManager.csrfToken; | ||
} | ||
} | ||
|
||
registerComponentManager(manager: LiveViewComponentManager) { | ||
this.componentManager = manager; | ||
} | ||
|
||
} |
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
Oops, something went wrong.