Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active March 26, 2018 19:27
Show Gist options
  • Save AdamBien/22275b3372aabe651953c0992689c6d9 to your computer and use it in GitHub Desktop.
Save AdamBien/22275b3372aabe651953c0992689c6d9 to your computer and use it in GitHub Desktop.
48thAirhacksQ&A.md
@frifle
Copy link

frifle commented Mar 26, 2018

Moin Adam,

thanks for your approach using plain standard javascript only. I really appreciate that and I think it is very helpful in long term support applications.
In my projects we are visualizing machine data in an ui. We are currently using javaFX and have to provide a web-ui in near future, for which we want to build a javascript-application. For us the main benefit of FX is databinding, esp because we have to deal with complex model objects. What do you think, how do you implement a two-way-databinding using plain javascript?

In practice a machine has a name, some main data and a set of sensors with number and data. An example json of a machine might be

{"name":"testMachine","main":{"valueA":47,"valueB":11},"sensors":[{"gauge":42,"sensor":12},{"gauge":3.14,"sensor":18}]}

The machine has a rest service to read and change main data, to read, add and remove sensors and to change some of sensor values. It also offers a web socket that pushes messages whenever sensors change (add, remove, change value).
The js-app visualizes that machine. It shows gauges with current sensor values and their variation in time. Even some meta-gauges that show calculated values. Further it offers input fields and submit-buttons to change the main and some sensor data.
In js-code we would like to have a single model-var with the machine data. We would like to bind that model with the web-socket,
the rest-calls and the several ui-dom objects.

How do you do that in plain standard js without ending up in a event-listener-hell?

Thanks, and greetings from Hamburg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment