Comments (2)
Hello @davedawkins,
The list of drawops is very functional, and has that pure (monadic) feel. However, even accepting that it's not a complete implementation, how would they encode constructs like conditionals, loops etc. For example, in JS
F# has a feature called "comprehension list" which allows you to have "branching decision" in the list.
let test =
[
"See how"
if true then
"this line is shown"
if false then
"but not this line"
]
String.concat "\n" test |> printfn "%A"
I think it should works for the case you mentionned in point 1.
Would having an alternative to the drawOps property, such as an imperative effectful drawUsingContext be a useful addition? drawOps would ultimately be handled by the default drawUsingContext. So, indirecting the call from react_canvas.js to Canvas.drawOps via a function in the component props. I see from another issue there is concern about the GC pressure from the drawOps array. Would this side-step the issue? The other discussion also seemed to be happy with imperative-style drawing handlers. Eg
Yes, having an imperative code of just mapping/using the native JavaScript lowser the pressure on the GC.
This prototype version https://github.com/MangelMaxime/Elmish.Canvas/tree/feature/standalone_impl/src was doing much better.
It is not using Elmish at the moment, but the plan was to take inspiration from the Elmish loop system but plug it into an optimized "gameloop handler" that's why their is stuff like:
begin
-> elmish equivalent could beinit
update
-> elmish equivalent could beupdate
draw
-> elmish equivalent could beview
- etc.
The missing part is input handling and I woud have written it has a module where you can read the current input state. By that, I mean the user would not subscribe to mouse event or keyboard event.
The system would take everything for them and they would just do if System.Mouse.IsJustPress ...
or System.Keyboard.KeyDown "up" then ...
You can see an implementation of this system in my Hink experimentation:
Hink was a experimentation for creating Immediate an mode UI library in F#.
En excellente video explaining Immediate mode UI: https://caseymuratori.com/blog_0001
Or I made a talk presenting Hink and what Immediate mode UI is if you are curious : https://www.youtube.com/watch?v=mU6iuyf7o9g
Input systems of Hink: https://github.com/MangelMaxime/Hink/tree/master/src/Inputs
Lastly, given that it's been 2 years and we have a new Fable (v3), etc, is there any change in your thinking about how to integrate HTML Canvas with Elmish? For me, I would like an overall Elmish UI, but with a canvas that I can render to (performantly, and simply). This is the closest project that I can see!
Well, even when working on the prototype I discovered that using list would not work for performance reason. I guess, it could be a matter of having the standalone implementation done and wiring thing using a react component props if interaction is needed.
And also, communication from the "canvas" app to the "elmish app/parent" could be done using custom events.
I hope that I have kind of answer your questions.
from elmish.canvas.
I somehow missed this detailed reply - thank you!!
from elmish.canvas.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elmish.canvas.