nopaque.App = class App { constructor() { this.data = {}; this.socket = io({transports: ['websocket'], upgrade: false}); this.ui = new nopaque.UIExtension(this); this.users = new nopaque.UsersExtension(this); } // onPatch(patch) { // // Filter Patch to only include operations on users that are initialized // let regExp = new RegExp(`^/users/(${Object.keys(this.data.users).join('|')})`); // let filteredPatch = patch.filter(operation => regExp.test(operation.path)); // // Handle job status updates // let subRegExp = new RegExp(`^/users/([A-Za-z0-9]*)/jobs/([A-Za-z0-9]*)/status$`); // let subFilteredPatch = filteredPatch // .filter((operation) => {return operation.op === 'replace';}) // .filter((operation) => {return subRegExp.test(operation.path);}); // for (let operation of subFilteredPatch) { // let [match, userId, jobId] = operation.path.match(subRegExp); // this.flash(`[${this.data.users[userId].jobs[jobId].title}] New status: `, 'job'); // } // // Apply Patch // jsonpatch.applyPatch(this.data, filteredPatch); // } init() { this.ui.init(); } };