summaryrefslogtreecommitdiffstats
path: root/examples/declarative/listmodel-threaded/dataloader.js
blob: eac747887acdfcf5a0e869e28f1fd692bf49cdf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// ![0]
WorkerScript.onMessage = function(msg) {
    console.log("Worker told to", msg.action);

    if (msg.action == 'appendCurrentTime') {
        var data = {'time': new Date().toTimeString()};
        msg.model.append(data);
        msg.model.sync();   // updates the changes to the list

        var msgToSend = {'msg': 'Model updated!'};
        WorkerScript.sendMessage(msgToSend);
    }
}
// ![0]