Callback Methods
Introduction
Typed JSON files can be affected by changes from the client or the server. This page describes callback methods for changes on the server side.
OnData
OnData
is the method that is called when the Data
property is set, as described in the data bindings section.
The OnData
method is usually used to initialize the parts of the view-model that cannot be initialized by setting the Data
property. Several examples of this can be found in the KitchenSink repo.
The basic structure for using OnData
looks like this:
HasChanged
And the same goes for HasChanged
- that method is always called when there is a change on a server side. But this time it indicates a change of a value in JSON root class.
To capture a change in a child subtree, it is efficient to define another partial class and use HasChanged method there.
This method implemented in the same way as OnData
- all the declaration is happening in the code-behind file.
Unlike OnData
the method HasChanged
is not that commonly used but only when there is a need for auto-committed database transactions every time data updates.
There is a quick example on HasChanged
usage:
Just to sum up methods purposes:
OnData
- triggered when the data property is changed.HasChanged
- triggered when the value is changed.
Last updated