Hyperfiddle Context –
@fiddle– metadata for this fiddle, e.g. :fiddle/markdown
Other than the above key, the context is a magic black box, unless you are implementing data driven widgets which are aware of Datomic schema, parsed Datomic query, etc.
- Hyperfiddle is a browser which is a special class of interpreter
- Many interpreters have a call stack to keep track of scope as an expression evaluates
- Hyperfiddle has a context which keeps track of metadata for the "focus point"
ctxparameter itself is a historical implementation detail and may eventually not be needed at all
data ontologies in the context
- Fiddle graph (links)
- Fiddle behaviors (query)
- Datomic resultset
- Specs and validation state
These overlapping ontologies are not cleanly separated into namespaces yet. In theory, you can drive our hypermedia controls from databases other than Datomic if you can provide the necessary metadata.
Context is hacky dynamic scope for deeply nested UIs. It lets you send values downtree without explicitly passing them through each intermediate layer.
Clojure has proper dynamic scope, but React.js breaks it: React.js "functions" don't evaluate depth-first like a traditional call stack, but rather "breadth first" (because it offers optimization opportunities) and this breaks dynamic scope. React's Context API is an attempt to get it back. We've had a bad time with React Context. Instead, we explicitly pass a
ctxaround as a value through each intermediate layer, as a React prop. For efficient reactive views, everything inside the ctx that might change, needs to be a stable reference and reactive (otherwise irrelevant updates will thrash the entire UI).
I suspect DataScript solves the same problem better — graph passing rather than tree passing — but we aren't there yet.