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(…)
})
)
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?
2 Replies
REEEEE
REEEEE2y ago
you might be able to just do () => tokens
Je Suis Un Ami
Je Suis Un AmiOP2y ago
Hmm. Let me try. Okay. That works. Guess it’s gonna be the same if the source is a Resource and other such things. Thank you.
Want results from more Discord servers?
Add your server