Hey gang, not much of an update this week. Just do...
# two-minute-week
r
Hey gang, not much of an update this week. Just documenting my struggles between wanting observable state and needing a centralised system to manage events. I tried to build my own system in a few days but soon realised there's a lot more I need to think about - and maybe there's some existing approaches you all know about that I could look into? In general, am trying to update state solely via a centralised event manager, but also use observables to automatically trigger those events (if that make sense) A messy sandbox you can play with can be found here: https://codesandbox.io/s/eve-test-04e75?file=/src/App.js

https://youtu.be/Hw4BgyWRAAA

👍 1
m
have you considered the elm architecture or similar? https://guide.elm-lang.org/architecture/
your demo has a really fine grained event generation, maybe a coarse grained one would do? like transactions?
r
Yeah it looks like I'm going for a elm-ish messaging architecture. I think I'm creating issues by have object both emit and listen to events. Maybe all updates should be dispatched via message... I was also wondering on how much detail to go into the events. I suppose it's a matter of exposing what data is most likely to be listened to, otherwise you'd just need to filer it out later right? Will definitely look into transactions! I've never even heard of them!
m
what I mean by them is that you bundle a group of mutations into a named thing and emit an event with the name of the thing and some extra parameters, much more semantic that emiting events every time you mutate a field
g
you might be interested in https://github.com/thefrontside/microstates microstates
r
@Mariano Guerra oh yes I think something like that will be needed but it might need to be in combination with the microevents so derived values can know when to update. @Garth Goldwater 🙌 looks super interesting, thanks! I look forward to see what it can do!
g
the youtube talks listed on the readme are super clear (to me at least)—might be worth checking out
fairly react-specific most of the time but i linked to the framework without the react integrations
m
What's different in your scenario then the problems redux solve? Mobx is also a widely used alternative
r
Yeah I basically want a cross between the two. I currently use something like mobx https://github.com/alloc/wana and I really like that api but something redux-like would be easier to manage as the app is getting larger. However, I do not enjoy using redux at all, there's lot of boilerplate, and I find it a bit cumbersome. So this is an attempt at a happy medium between the two.
It's all trying to solve the same problem - I'm just playing with ideas to find what requires the least cognitive effort for me as programmer.
e
@Ryan King you might consider looking at my Beads language. It has three aspects that relate to your work. It is a clean sheet approach and emits to raw JS with no external dependencies such as Rect, etc.. You declare a model as a graph database schema that will be filled in with data later with data. Then you write chunks of code that draw your screen using the model data in a pure manner (the view). The controller chunks are blocks of code appended to the view drawing subroutines. There is also the notion of a derived quantity which is lazily evaluated when it is referenced. The key advantage over your method is that if a view drawing function uses model variables, a, b and c, if any of those 3 variables change their value, then the draw chunk is re-executed. This is all tracked automatically without any the programmer having to declare dependencies, similar to how spreadsheets work, except that this is about re-executing drawing functions with memorized parameters, which is quite different than simple formulas being executed in topological order. It has a central event system called the Loom, which combines publish/subscribe, network, keyboard, mouse, timer events into one unified event stream, that is fed to the constellation of code chunks, based on their appropriateness for that event.
r
@Edward de Jong / Beads Project it does sound very nice. Honestly, it might be a risky business decision to adopt at this point. But I'd be happy to try to build something and provide feedback. Do you have links?
Or maybe you next video could be on how to set up beads?
e
@Ryan King per your request, i just added two videos on beads installation, one for mac one for windows, links on beadslang.com Beads doesn't really need installation as it it is just a few files surrounding an EXE, but you do have to add a chrome extension to run your local web apps, and of course the average person doesn't know about file associations on new suffixes.
Please let me know how hard it was to get going. If people have difficulties getting started they quit immediately.
r
Great maybe I can get some feedback for you over the weekend.