-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for light dom signal host, invokable api
- Loading branch information
1 parent
8790c39
commit 3470044
Showing
6 changed files
with
101 additions
and
24 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
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,35 @@ | ||
// FROM: https://lit.dev/playground/#gist=3a8740445931d4d3745509b093cec034 | ||
|
||
import type { WatchDirective } from '@lit-labs/signals'; | ||
|
||
export class SignalHost { | ||
private isPendingUpdate = false; | ||
|
||
private __pendingWatches = new Set<WatchDirective<unknown>>(); | ||
|
||
protected _updateWatchDirective(directive: WatchDirective<unknown>): void { | ||
this.__pendingWatches.add(directive); | ||
this.requestUpdate(); | ||
} | ||
protected _clearWatchDirective(directive: WatchDirective<unknown>): void { | ||
this.__pendingWatches.delete(directive); | ||
} | ||
|
||
protected requestUpdate() { | ||
if (this.isPendingUpdate) return; | ||
|
||
this.isPendingUpdate = true; | ||
|
||
queueMicrotask(() => { | ||
try { | ||
for (const directive of this.__pendingWatches) directive.commit(); | ||
} catch { | ||
// Empty | ||
} finally { | ||
this.__pendingWatches.clear(); | ||
} | ||
|
||
this.isPendingUpdate = false; | ||
}); | ||
} | ||
} |
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 +1,4 @@ | ||
import '@gracile/client/hydration-client-route'; | ||
export { | ||
type HydrationOptions, | ||
createHydrationRoot, | ||
} from '@gracile/client/hydration-client-route'; |
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