Understanding events & forest #249
cruxcode
started this conversation in
Guides: Atri Framework Reference
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you look at the
localdb/.../events.json
file, you will notice that it contains an array of events. There are six types of events as of now:localdb
which stores all the components on the canvas in JSON format.lodash
library. Some use cases of this event are an update to the styles of a component or the parent node of that component which happens in case of repositioning of that node in the tree.["styles", "background"]
, then, this event will removebackground
field.When you drag and drop a component onto the canvas, the natural perception is that one event will get fired. But actually, this might or might not be the case. When we create a component in the backend we have to store initial props, initial callbacks, and create components. Each of these has an event associated with them, we also give an alias and that also is the cause of firing one more event. Since all these events are associated with one single action and hold a semantic meaning together, we need to know about the entire group of these events. Hence, we group the events semantically and send an array of events in response which holds the entire group of events.
A separation exists on the tree level, if we update only the CSS by some action only the CSS tree is affected and gets updated.
The entire structure of an application in the backend is stored in the form of a forest. Forest is a terminology meaning "tree of trees", as of now we have four different trees:
A node in the component tree is linked to its respective nodes in CSS, callbacks, and custom props trees.
A
subscribeForest
function enables us to receive updates for the events if we have subscribed to that particular update. So when any particular event happens in the subscribed forest, we'll receive the updates for that.If any user action is causing the firing of 'n' events, the
subscribeForest
is also called 'n' times. Whenever any event happens and we have subscribed to the forest, it emits an event indication of what has been updated along with its metadata and the name of the semantic group that the event was a part of.Apart from the 6 types of events, we also have 6 types of updates which are listed below:-
A question arises-
Q. Why do we have these update types when we already have event types?
A. On repositioning a patch event gets generated but the same patch event is generated on changing any styles property. We treat repositioning patch events in a special way and for that we have added a layer of abstraction that can tell whether the update is for
updating the data inside a node or the position of a node. Also, a patch event and a hard-patch event fire the same
change
update.Beta Was this translation helpful? Give feedback.
All reactions