SolidJSS
SolidJS3y ago
3 replies
Je Suis Un Ami

Creating an Observable from a store.

Is there a way I can create an observable from a store?

Essentially, what I want to do this:
import { observable } from “solid-js”;
import { createStore } from “solid-js/store”;
import { tap, map } from “RxJS/operators”;
import {from } from “RxJS”;

Interface AuthTokens {
   access: string;
   refresh: string;
}

const [tokens, setTokens] = createStore<AuthTokens>({});

const tokens$ = observable(tokens).pipe(
   tap(value => //save to storage),
   map(tokens => {
      return from(fetch(…)).pipe(…)
   })
)

Or, something like that at least.

This fails because the observable() function accepts an Accessor, which pretty much is only signals. Is there a way I can make it work with stores as well?
Was this page helpful?