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
REEEEE14mo ago
you might be able to just do () => tokens
Je Suis Un Ami
Je Suis Un Ami14mo 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.