Hyperfiddle Context – ctx

  • @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.

explanation

  • 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"
  • The ctx parameter 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.

internals

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 ctx around 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.
  1. Getting Started
  2. Overview
  3. Tutorial
    1. Simple blog
    2. Seattle
  4. Concepts
    1. Design
    2. Technology Vision
    3. I/O Runtime
    4. Transactions
    5. Foreign integrations
    6. ctx
  5. Guides
    1. hyperfiddle.ui
    2. Select options
  6. Triage
    1. Architecture braindump
    2. Technical braindumps
    3. hyperfiddle.jar