How can I react to additions and deletions of keys in a scope object as well as to changes to sub values?
The new version of plunker has the concept of a scratch. The scratch is the current state of the editor that can periodically be saved as a plunk. The scratch is structured as follows:
{
files: {
"index.html": {
filename: "index.html",
content: "<h1>Html goes here</h1>"
}, /* More files... */
}
}
The scratch is defined as a directive and so I can't seem to get access to the parent scope to broadcast events. See scratch.coffee.
Because the scratch is the authority on what is in the current edit session, it seems normal that it should generate the events that would allow other components (the ace textarea) to react to file additions/deletions/changes.
With things organized as described above, I can't figure out how to let the scratch
remain the authority on edit session state while allowing it to 'notify' other components of changes to its structure.
Any ideas?
Looks good except for one thing: you are expecting
ace
,file
andhistory
to be present on the current scope that that the directive is placed into.This implicit dependency leads to code that is hard to maintain as it grows. That's why we have a concept of isolate scopes, these scopes don't inherit from their prototypical parents and allow you to create truly encapsulated and thus reusable components. Check out: https://github.com/IgorMinar/ng-todo/blob/demo-throneofjs/todo.js#L51-53