webapp/src/stores/zine/currentArticle.ts
2022-09-09 14:53:35 +03:00

19 lines
470 B
TypeScript

import { atom, WritableAtom } from 'nanostores'
import type { Shout } from '../../graphql/types.gen'
import { useStore } from '@nanostores/solid'
let currentArticleStore: WritableAtom<Shout | null>
// TODO add author, topic?
export const useCurrentArticleStore = (initialState: Shout) => {
if (!currentArticleStore) {
currentArticleStore = atom(initialState)
}
const getCurrentArticle = useStore(currentArticleStore)
return {
getCurrentArticle
}
}