A Brief Introduction to Gjallarhorn
Gjallarhorn is centered around two core types - Signals and Mutables.
A signal represents a value that changes over time, and has the following properties: - A current value, which can always be fetched - A mechanism to signal changes to subscribers that the value has been updated
A Mutable is a holder for mutable variables, similar to a reference cell. They are typically created via Mutable.create:
1: 2: 3: 4: 5: 6: 7: 8: |
|
In this simple example, we show creating, reading from, and updating a Mutable.
Mutable variables in Gjallarhorn have some distict features:
- Very low memory overhead: When created, a mutable like the one above has no memory overhead above that of a standard reference cell. It is effectively nothing but a thin wrapper around the current value, without any extra fields.
- They expose themselves as a signal - there is always a current value and they can notify subscribers of changes
Once your core data is held within a Mutable or pulled in via something that provides a signal, you can use the Signal module to transform the data
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
|
Next, we'll go into more details about signals.
val variable : obj
Full name: Intro.variable
Full name: Intro.variable
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val first : obj
Full name: Intro.first
Full name: Intro.first
val last : obj
Full name: Intro.last
Full name: Intro.last
val full : obj
Full name: Intro.full
Full name: Intro.full