Open jldec opened 1 month ago
Regarding the framework adapter:
Exposing RxJS Observables has high interop. The only "adapter" (just a binding function) that UI frameworks would need is to .subscribe
.
In Solid land this is as simple as:
function Component(){
const message = from(project.query.message.subscribe("blabla"))
return <>{message()}</>
}
https://docs.solidjs.com/reference/reactive-utilities/from
In React land
function Component(){
const message = useObservable(project.query.message.subscribe("blabla"))
return <>{message}</>
}
https://github.com/crimx/observable-hooks
Hence, I think going with RxJS for internal reactivity and exposing observables via .subscribe is our easiest path to put the reactivity discussions behind us. cc @martin.lysk1
Agree - any thoughts on this one from you @jan.johannes
Thanks for the feedback 🙏
Here's a quick TL;DR of how I'm thinking about the api layers for now.
Internal means below the ===
line.
UI code
- - - - - - - - - - - - - - - - - -
UI framework adapter
- - - - - - - - - - - - - - - - - -
generic reactive api: RxJS ?
===================================
js subscribe (e.g. to CRUD events)
- - - - - - - - - - - - - - - - - -
messages CRUD api (not reactive)
- - - - - - - - - - - - - - - - - -
store api (DB/files)
To be extra clear @martin.lysk1, I don't think we want reactivity in the bottom layers, even knowing that we want observable database queries in the future.
At the time when we have lix apis for change-tracking on a DB, we can look at DBs with watchable queries, but I did not interpret @samuel.stroschein's suggestion for RxJS to mean that we should implement this in our v2 store using RxJS internally.
The v2 store is a very bare-bones database designed to live in text files versioned by git while we continue working on lix.
What is the generic reactive api? JS subscribe can be applied to any api no?
for example:
project.settings.subscribe()
i would prob also change the api to project.{api}.get|set|subscribe:
project.settings.get()
project.settings.set()
project.settings.subscribe()
get()
.subscribe()
to a frameowkrs reactive system is all thats neededbut I did not interpret @samuel.stroschein's suggestion for RxJS to mean that we should implement this in our v2 store using RxJS internally.
Yep. Doesn't have to use rxjs internally BUT Ui state always needs to be correct. wiring everything manyally will be hard ( i assume). you can try a non rxjs implementation. if bugs pop up, we will know why
change the api to
project.{api}.get|set|subscribe
What is the generic reactive api? JS subscribe can be applied to any api no?
This was just my interpretation of the app-facing RxJS api suggestion you made earlier. I agree that we should start with a basic subscribe first.
change the api to project.{api}.get|set|subscribe
Do you have a sense of where query() might fit in this model?
No. Except that we can prob drop the .query.*
namespace.
project.messages.get()
project.messages.update()
project.messages.*
project.messages.subscribe()
project.lintReports.update()
project.lintReports.subscribe()
I do wonder how we might incorporate @felixhaeberle 's request for projectList.subscribe in MESDK-36
Yep. probably with the same pattern. Although, we break tree-shaking here.
listProjects.get()
listProjects.subscribe()
Yep. probably with the same pattern.
Agree 👍
MESDK-109
Capturing here for wider readability.
This tasklist describes the steps toward full persistence and apis for v2 MessgaeBundles. This is part of an ongoing effort to streamline the sdk architecture as described in https://github.com/opral/inlang-message-sdk/issues/15.
subscribe
api which does not depend on solidjs. PR 2913