Closed onsetsu closed 5 years ago
we have that unified place now: lively4fetchHandlers
use it like this:
if (self.lively4fetchHandlers) {
// remove old instances of me
self.lively4fetchHandlers = self.lively4fetchHandlers.filter(ea => !ea.isNavbarHandler);
self.lively4fetchHandlers.push({
isNavbarHandler: true,
handle(request, options) {
// do nothing
},
async finsihed(request, options) {
var url = (request.url || request).toString()
var method = "GET"
if (options && options.method) method = options.method;
if (method == "PUT" || method == "DELETE") {
try {
for(var container of document.querySelectorAll("lively-container")) {
var navbar = container.get("lively-container-navbar")
if (navbar && navbar.onObserveURLChange) {
await navbar.onObserveURLChange(url, method)
}
}
} catch(e) {
console.error(e)
}
}
}
})
}
Currently, we have multiple locations, in which we signal different parts of the system, that some file updated, e.g.:
LivelyEditor::updateOtherEditors
updates other (unchanged) editorsLivelyContainer::updateOtherContainers
similarly, updates other containers-> When saving a file, both of the above are executed in (asynchronous) sequence. I wondered if we could implement a
fileUpdated(url, excluded)
utility that would do this in one go.Why would this be useful? Other parts of the system could also signal updates to files, without having to use an editor or a container.