Clean up store types & initial values
Treating these as Readable for better safety from consuming code Fixes #10
This commit is contained in:
@@ -9,13 +9,13 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { getContext, onDestroy, setContext } from "svelte";
|
||||
import { writable, Writable } from "svelte/store";
|
||||
import { Readable, writable, Writable } from "svelte/store";
|
||||
type OnUpdate = (message: StackMessage, element: HTMLElement) => void;
|
||||
|
||||
export let onUpdate: OnUpdate | undefined;
|
||||
export let element: HTMLElement | null;
|
||||
|
||||
let parentUpdateStore: Writable<OnUpdate> | undefined =
|
||||
let parentUpdateStore: Readable<OnUpdate> | undefined =
|
||||
getContext(STACK_CONTEXT_NAME);
|
||||
let notifyStore: Writable<OnUpdate> = writable(() => {});
|
||||
setContext(STACK_CONTEXT_NAME, notifyStore);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getContext, setContext } from "svelte";
|
||||
import type { Writable } from "svelte/store";
|
||||
import type { Readable, Writable } from "svelte/store";
|
||||
|
||||
export enum State {
|
||||
Open,
|
||||
@@ -11,7 +11,7 @@ export function hasOpenClosed() {
|
||||
return useOpenClosed() !== undefined;
|
||||
}
|
||||
|
||||
export function useOpenClosed(): Writable<State> | undefined {
|
||||
export function useOpenClosed(): Readable<State> | undefined {
|
||||
return getContext(OPEN_CLOSED_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user