Closed samuelstroschein closed 1 year ago
@janfjohannes do you want to implement an async primitive while you factor out lix/reactive
, see
_https://github.com/inlang/inlang/pull/1142#discussion_r1305526884_
@janfjohannes why does lix depent on inlang/app?
If we want to share reactive primitives, lets extract the reactive primitives and adapters from inlang/app to lix/reactive-primitives or something.
The logical deduction is that "inlang is a lix app". Not the other way around "lix is an inlang app"
@samuelstroschein i did a first version using the same solid to subscribable method as in inlang/app, there were stil too many open questions to do somthing propper and did not want to block @NilsJacobsen any more.
i think we need a proper working session to make a good plan as you said, this should play nicely with awaitng and async. i really currently fancy something using async iterables as this allows awaiting and has native js support but i am not 100% sure about this.
@janfjohannes we should ask in the solid discord what they recommend/what's upcoming in solidjs 2.0. i heard that solid 2.0 has first class async support. coordinate with @ivanhofer pls. it's clear that we need sync and async reactivity for both inlang and lix/client
@samuelstroschein i checked in the rxjs froums and they have solved it in rxjs 7 like this, and they also have a subscribable:
// these are awaitable
await rxjs.lastValueFrom(inlang.someapi.something)
await rxjs.firstValueFrom(inlang.someapi.something)
however as in a reactive system the subscribable never completes until the reactivity is disposed we probably need somthing liek await nextValueFrom(inlangApiObservable) wher the promise would resolve when the next value is produced after the subscription is started
@ivanhofer you know solid much better than me and also had interactions with the team before, could you get feedback for a best practice from solids perspective?
@janfjohannes the solid community is friendly. I would ask in the #reactivity channel. Say that you come from inlang.
PS we are in elaborating a sponsorship for solidjs. If solid (2.0) suits out use case for lix and inlang reactivity best, we sponsor them for ongoing support/use inlang to build their i18n stuff
It seems to me that we need an asyncSignal
primitive. Solid offers resource
maybe that's what ne need.
signal()
asyncSignal()
derived()
effect()
I'm gonna make some tryouts today. Will discuss the outcome with you later.
@NilsJacobsen
The API I have in mind is
const lint = asyncSignal(() => lintMessages({}))
await lint()
Questions:
Looks good, Under the hood, we also want lint to be an async subscibable right? And then with the adapter an async signal. I'm gonna start experimenting with lint.
Looks good, Under the hood, we also want lint to be an async subscibable right? And then with the adapter an async signal.
Yes, an async subscribable entails that we need an async signal.
Okey what I have right now is that createAsyncSubscribable
export function createAsyncSubscribable<T>(
signal: () => T,
init: () => Promise<void>,
): AsyncSubscribable<T> {
const asyncSignalGetter = async () => {
await init()
return signal()
}
return Object.assign(asyncSignalGetter, {
subscribe: (callback: (value: T) => void) => {
createEffect(() => {
callback(signal())
})
},
})
}
leads to this usage:
await inlang.lint() //get value
inlang.lint.subscribe((m) => console.log(m)) // access callback
await inlang.lint() // TODO: get signal, does not work right now
The whole topic is getting more and more complex. Maybe let's discuss tomorrow morning how we can make it work this week.
We have a hacky implementation in place. Future update will follow
Discussed in https://github.com/inlang/inlang/discussions/1272
Sub-tasks