enableExternalSource
Registers a factory that bridges external reactive systems (e.g. MobX, Vue refs) into Solid's tracking graph. Every computation will be wrapped so that the external library can track its own dependencies alongside Solid's.
Multiple calls pipe together: each new factory wraps the previous one.
Import
import { enableExternalSource } from "solid-js";Type signature
function enableExternalSource(config: ExternalSourceConfig): void;Parameters
config.factory
Receives (fn, trigger) — wrap fn execution in external tracking,
call trigger when external deps change. Return { track, dispose }.
config.untrack
Optional wrapper for untrack — disables external tracking too.
Examples
// Bridge an external "subscribe / notify" library into Solid's graph.// `factory` wraps every Solid compute so the external library can attach// its own dependency tracker; `trigger` re-runs the compute on external// change. `untrack` mirrors Solid's `untrack()` into the external library// so that reads inside `untrack(...)` don't get tracked twice.enableExternalSource({ factory: (compute, trigger) => { const sub = externalLib.subscribe(trigger); return { track: (prev) => externalLib.run(() => compute(prev)), dispose: () => sub.unsubscribe(), }; }, untrack: (fn) => externalLib.untracked(fn),});Related types
ExternalSource
interface ExternalSource { track: (prev: any) => any; dispose: () => void;}track
- Type:
(prev: any) => any
dispose
- Type:
() => void
ExternalSourceConfig
interface ExternalSourceConfig { factory: ExternalSourceFactory; untrack?: <T>(fn: () => T) => T;}factory
- Type:
ExternalSourceFactory
untrack
- Type:
<T>(fn: () => T) => T
ExternalSourceFactory
type ExternalSourceFactory = ( fn: (prev: any) => any, trigger: () => void) => ExternalSource;