SimpleDataField and compute frequency

Hello,

This has probably been asked before and if so I apologize...

When using SimpleDataField the compute method is called once every second. Is that true even if the field isn't visible?

The documentation for DataField says compute is called every second by the system and since SimpleDataField is a subclass I guess it's true there as well.

I'm not sure how to simulate this in the simulator. If I select Settings->force onHide compute isn't called until I force onShow but maybe this isn't the same thing as switching to another screen during an activity?

Best regards,
Tobias
  • I've never tried to simulate this in the simulator, (It's a simulator and not an emulator) but on a watch yes, compute() does get called every sec even if the df isn't visible.
    If you want to verify it, you can sideload something like this on a device. All it does is track now many times compute is called, and if you switch to a different screen for some time and come back, you'll see compute() was called while the DF wasn't visible.

    using Toybox.WatchUi as Ui;

    class sdfView extends Ui.SimpleDataField {
    var i=0;

    //! Set the label of the data field here.
    function initialize() {
    SimpleDataField.initialize();
    label = "called";
    }

    function compute(info) {
    i++;
    return i;
    }

    }
  • Former Member
    Former Member over 9 years ago
    Compute should continue to run when you use Force onHide in the simulator.

    I've created a ticket to investigate this.