#Creating an Observable from a store.

3 messages · Page 1 of 1 (latest)

livid sky
#

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?

ivory pollen
#

you might be able to just do () => tokens

livid sky
#

Hmm. Let me try.