zk-and-rx"

From Documentation
Line 6: Line 6:
  
 
= Introduction =
 
= Introduction =
 +
 +
Assume you are working for a project on a Robot Farm (I think there could be worse projects). Unfortunately those Robots are a bit moody and unreliable sometimes - so of course there needs to be a supervisor sitting in his/her office chair and watching a screen to follow all the Robots movements.
 +
 +
Since human supervisors are prone to errors too there should be multiple employees observing the same Robots simultaneously.
 +
 +
Based on their current interest and in order to preserve bandwidths (of course we need a web interface) it must be possible to track certain Robots near real-time without completely losing track of the overall situation (i.e. different groups of Robots have different update intervals in the UI).
 +
 +
Employees may come and go as they like and connect/disconnect to the live data feed on demand.
 +
 +
However the Robots are constantly sending data at high frequency to your back-end process.
 +
  
 
== The Backend (RX Observable) ==
 
== The Backend (RX Observable) ==

Revision as of 08:26, 21 September 2017

Documentationobertwenzel
obertwenzel

Author
Robert Wenzel, Engineer, Potix Corporation
Date
September, 2017
Version
ZK 8.5

Introduction

Assume you are working for a project on a Robot Farm (I think there could be worse projects). Unfortunately those Robots are a bit moody and unreliable sometimes - so of course there needs to be a supervisor sitting in his/her office chair and watching a screen to follow all the Robots movements.

Since human supervisors are prone to errors too there should be multiple employees observing the same Robots simultaneously.

Based on their current interest and in order to preserve bandwidths (of course we need a web interface) it must be possible to track certain Robots near real-time without completely losing track of the overall situation (i.e. different groups of Robots have different update intervals in the UI).

Employees may come and go as they like and connect/disconnect to the live data feed on demand.

However the Robots are constantly sending data at high frequency to your back-end process.


The Backend (RX Observable)

Hot Observable

  • constantly streams events, at short intervals (but unreliable maybe skipping information)
  • allows multiple consumers

The UI (ZK MVVM application)

  • render robots as divs + dynamic styles reacting on robot status (position, mood)

The Magic in the Middle

  • filter the events (by selectable criteria)
  • throttle UI updates (reducing the network load)
    • buffer updates (100ms / 1000ms)
    • avoid redundant updates
    • batch update (in a single ZK execution)

Summary

Example Sources

The code examples are available on github in the zk-rxdemo repository

Running the Example

Clone the repo

   git clone [email protected]:zkoss-demo/zk-rxdemo.git

The example war file can be built using the gradle-wrapper (on windows simply omit the prefix './'):

   ./gradlew war

Execute using jetty-runner (fastest):

   ./gradlew startJettyRunner

Execute using gretty:

   ./gradlew appRun


Then access the example http://localhost:8080/zk-rxdemo CHECK LINK


Comments



Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.