https://github.com/genieframework/stipplemathjs.jl
Support of mathjs and complex numbers in Stipple
https://github.com/genieframework/stipplemathjs.jl
Last synced: 4 months ago
JSON representation
Support of mathjs and complex numbers in Stipple
- Host: GitHub
- URL: https://github.com/genieframework/stipplemathjs.jl
- Owner: GenieFramework
- License: mit
- Created: 2023-11-14T18:38:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-20T23:38:30.000Z (over 1 year ago)
- Last Synced: 2025-10-24T21:00:44.153Z (9 months ago)
- Language: Julia
- Size: 239 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StippleMathjs
StippleMathjs adds [mathjs](https://mathjs.org/) to your [Stipple](https://github.com/GenieFramework/Stipple.jl) or [GenieFramwork](https://github.com/GenieFramework/GenieFramework.jl) project.
Furthermore, it adds automatic conversion of all types of `Complex` numbers between server and client.
# Example App
```julia
using Stipple, Stipple.ReactiveTools
using StippleUI
using StippleMathjs
x0 = 1.0
y0 = 2.0
@app begin
@in x = x0
@in y = y0
@in z = x0 + y0 * im
@in z2::ComplexF64 = x0 + y0 * im
@onchange x, y begin
# update z without triggering `@onchange z`
z[!] = x + y * im
# update x and y of the client(s)
@push z
end
@onchange z begin
# update x and y without triggering `@onchange x, y`
x[!] = z.re
y[!] = z.im
# update x and y of the client(s)
@push x
@push y
end
end
@deps StippleMathjs
function ui()
[
card(class = "q-pa-md", [
numberfield(class = "q-ma-md", "x", :x)
numberfield(class = "q-ma-md", "y", :y)
])
card(class = "q-pa-md q-my-md", [
row([cell(col = 2, "z"), cell("{{ z }}")])
row([cell(col = 2, "z.mul(z)"), cell("{{ z.mul(z) }}")])
row([cell(col = 2, "z.abs()"), cell("{{ z.abs() }}")])
btn(class = "q-my-md", "square(z)", color = "primary", @click("z = z.mul(z)"))
])
]
end
@page("/", ui, debounce = 10)
up()
```

The example app with a correct Manifest.toml is available on [StippleDemos.jl](https://github.com/GenieFramework/StippleDemos/tree/master/AdvancedExamples/StippleMathjsDemo)
### Note
- Due to a current bug in Stipple you need to define `x0` and `y0` outside the loop in order to guarantee that z is of the correct type.
Alternatively, you could declare `z` explicitly, e.g. as `z::ComplexF64`
- This package can serve as a good example how to embed other javascript sources into your own project.