Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define(['durandal/app'], function (app) {
- var message = ko.observable();
- var canPublish = ko.computed(function () {
- return message() ? true : false;
- });
- return {
- message: message,
- canPublish:canPublish,
- publish: function () {
- app.trigger('sample:event', message());
- }
- };
- });
- define(['durandal/app'], function (app) {
- return {
- received: ko.observableArray([]),
- subscription:ko.observable(),
- subscribe: function () {
- var sub = app.on('sample:event').then(function(message) {
- this.received.push(message);
- }, this);
- this.subscription(sub);
- },
- unsubscribe: function () {
- this.subscription().off();
- this.subscription(null);
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement