can.onPatches
Defines how to listen to patch changes on an object.
@can.onPatches( handler(patches), queueName )
The @can.onPatches
symbol points to a function that registers
handler
to be called back with an array of changes that have happened
on the client.
The following mutations on a list-like object will produce the patch objects in the comments:
const list = [];
list.count = 3000; //-> {type: "add", key: "count", 3000}
list.push( "a" ); //-> {type: "splice", index: 0, insert: ["a"]}
Parameters
- handler
{function(patches)}
:The string key to bind on changes to. The handler must be called back with an array of Patch objects.
- queueName
{String}
:The [can-queues] queue the
handler
should be enqueued within. Defaults to"mutate"
.