NodeCode Views

In this doc we will talk about Views and what they are used for as well as give a simple example.
1/7/2017 11:45:01 PM
Last Updated:
1/26/2017 1:33:12 AM


What is a NodeCode View?


Views are a NodeCode feature that allows us, as humans, to interact with the data as it flows!


If you've read some of the other documentation, you are probably getting a good sense of how data flows between devices using Services and the Services' Nodes.  Just having this ability is great from an automation point of view but what if we wanted to interact with our NodeCode programs more directly? What if we want to be a part of the program?  What if we want to kick off a flow or see what  data is that is flowing through the datastreams? Views!


Views, just like Nodes, have Inputs and Outputs.  Unlike the Nodes, though, Views are for humans instead of other Services.


You can create a View from within NodeCode Studio under a Hubs View page. 



Once the View is created you can select it from the Views list, rename it and start designing the View using the simple View Canvas.

Designing a View simple consists of setting the number of Columns and Rows your View should have and then dragging and dropping View Elements onto the Canvas. 



Make sure to save the View when you are finished or you could lose your changes and/or leave the View in an in-between state.

Once you've saved your View, you can drag and drop onto one of your Program Canvases.



You will see that there is a one-to-one relationship between the View Elements you created on the View and the rows of inputs and outputs on the View you added to the program.  You can wire up the Inputs and Outputs with your existing Nodes as just as if they were other Nodes.



These Views are accessable by right-clicking on the View within the Program (in which the View exists) and clicking 'Show'. Views are also automatically available on the NodifyMe app (assuming it is already connected to your Hub).

You will now be able to send and receive data in real-time just as a Node would just by using the different View Elements.

In this example photo, a connection is made between the Switch View Element and a GPIO pin on a Raspberry Pi. When the View's switch is clicked, it turns on the LED connected to the GPIO pin.




 In this example program, if you close the View window, you will see the switch in the off state, even though the GPIO pin is set to on. To fix this, simple drag another connection from the LED output to the input of the Bool (Switch) View Element.



When you open the LED View now, the View will query the current state of the LED output, update the View Element and will receive real-time updates going forward (as long as the View is open).


All Views connected to the Hub, whether through NodeCode Studio or the NodifyMe app should all update at the same time (or as fast as the network allows) allowing many users to see the same data simultaneously.



When a View is open in either NodeCode Studio or the NodifyMe app, you will receive updates from all Nodes that are connected to any of the open View's View Element input.  Keep this in mind if you are on a metered network connection.



We've found that it is better in many cases to have more Views with fewer elements than a few Views crammed with a lot of elements.

It is easier to keep things organized, the elements aren't too small and there are performance/data benefits as well, especially on mobile devices where you may only need updates from one Node.

Back to List