Skip to content

Commit

Permalink
Merge pull request #8 from gagan-suie/main
Browse files Browse the repository at this point in the history
Feat: added svelte stores
  • Loading branch information
gagansuie authored Dec 5, 2022
2 parents 34c3948 + e531194 commit 4d45d43
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 4d45d43

Please sign in to comment.