Feature request: alien-signals adapter #1344
nickchomey
started this conversation in
Ideas
Replies: 1 comment
-
I just took a look at alien signals. A possible implementation could look like this (untested): import { signal, pauseTracking, resumeTracking } from 'alien-signals'
import { createReactivityAdapter } from '@signaldb/core'
const alienSignalsReactivityAdapter = createReactivityAdapter({
create: () => {
const dep = signal(0)
return {
depend: () => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
dep()
},
notify: () => {
pauseTracking()
const currentValue = dep()
resumeTracking()
dep(currentValue + 1)
},
}
},
isInScope: undefined,
onDispose: undefined,
})
export default alienSignalsReactivityAdapter However, it seems like the current implementation doesn't offer a way to check whether the current code runs inside of a reactive scope, nor a way to clean up things after a reactive scope is closed. Therefore, I would consider this as "experimental." |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Alien signals seems to be the fastest library around, and is also becoming quite popular (vue 3.6 will be using it).
https://github.com/transitive-bullshit/js-reactivity-benchmark
There's also a deep signals implementation if that's something useful here.
https://github.com/CCherry07/alien-deepsignals
There's also a promising version built with the tc39 signals proposal api. proposal-signals/signal-polyfill#44
Beta Was this translation helpful? Give feedback.
All reactions