Listening for Property Changes

    Listening for Property Changes


    Article summary

    Listening for Property changes

    With Firebolt® you can get and listen for property changes on an X1 Device. This includes both the hardware and system properties such as audio, current accessibility settings, and all the mutable properties of an X1 Device.

    Each Firebolt® property comes with the following abilities:

    • Get the property at a specific time.

    • Listen for when that property changes, such as when a user changes their X1 Device name from "Living Room TV" to "Bedroom TV".

    This is useful in instances where you want to:

    • Retrieve a specific X1 Device setting

    • You can retrieve the current state of a property. For instance, using the Accessibility module you can get back the user's closed captions settings.

    • Checking device property states

    • You can check the current state of a property. For instance, using the Device module you retrieve how the X1 Device is connected to the internet or if it's connected at all.

    • Receiving property state updates when they change

    • You can listen for when a property changes such as when a user changes an X1 Device setting or adjusts their profile.

    Listening for a Property to Change

    You can receive property state updates when a change occurs in a specific property. To create a property listener for a specific property and have it do something or return something is the same syntax across each Firebolt® module. To listen for a property, change the syntax to:

    <Module>.<property>( value => {
      // this code gets the new value when it changes
    })
    

    Listening for a change in the device's network connectivity status

    If you wanted your App to receive a notification that the network value changed on the X1 Device, (e.g., react to when a user is no longer connected to the internet) it would look like this:

    Device.network( value => {
      console.log(value)
    })
    

    In the above example, the new value is printed to a console log.

    If you were to run the above, it would look something like this:

    {
      {
        "state":"connected",
        "type":"WIFI"
    }
    

    To see the current list of return values for the network method based on the device go to Device.network.

    Related Information

    • Dependencies

      • Firebolt® 0.6.0 and Higher


    Was this article helpful?

    What's Next