Skip to content

Instantly share code, notes, and snippets.

@spion
Last active July 5, 2025 12:52
Show Gist options
  • Save spion/00b2f2caabdfd0ea8c20dbfcff482ef2 to your computer and use it in GitHub Desktop.
Save spion/00b2f2caabdfd0ea8c20dbfcff482ef2 to your computer and use it in GitHub Desktop.
import { Reaction, untracked } from 'mobx'
import { enableExternalSource } from 'solid-js'
let id = 0
enableExternalSource((fn, trigger) => {
const reaction = new Reaction(`externalSource@${++id}`, trigger)
return {
track: x => {
let next
reaction.track(() => (next = fn(x)))
return next
},
dispose: () => {
reaction.dispose()
},
}
}, untracked)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment