Skip to content

Commit

Permalink
Feat: added svelte stores
Browse files Browse the repository at this point in the history
  • Loading branch information
gagansuie committed Dec 5, 2022
1 parent 8beae1f commit e531194
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Empty file added src/stores/authStore.ts
Empty file.
24 changes: 24 additions & 0 deletions src/stores/channelStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { derived, writable, type Writable } from "svelte/store"

class ChannelStore {
constructor(
public firstname: Writable<string> = writable(''),
public lastname: Writable<string> = writable(''),
) { }

get fullname() {
// Use derived to access writable values and export as readonly
return derived(
[this.firstname, this.lastname],
([$firstName, $lastName]) => {
return $firstName + " " + $lastName
}
)
}
}

// Export a singleton
export const myFormStore = new ChannelStore()

// Allow for multiple stores (good for contexts)
// export const createMyFormStore = () => new MyFormStore();
Empty file added src/stores/streamStore.ts
Empty file.

0 comments on commit e531194

Please sign in to comment.