webapp/src/stores/zine/currentArticle.ts
2022-09-13 12:30:36 +02:00

26 lines
565 B
TypeScript

import { atom, WritableAtom } from 'nanostores'
import type { Shout } from '../../graphql/types.gen'
import { useStore } from '@nanostores/solid'
let currentArticleStore: WritableAtom<Shout | null>
type InitialState = {
currentArticle: Shout
}
export const useCurrentArticleStore = ({ currentArticle }: InitialState) => {
if (!currentArticleStore) {
currentArticleStore = atom(currentArticle)
}
// FIXME
// addTopicsByAuthor
// addAuthorsByTopic
const getCurrentArticle = useStore(currentArticleStore)
return {
getCurrentArticle
}
}