antonmedv / monkberry

Monkberry is a JavaScript library for building web user interfaces
https://monkberry.js.org
MIT License
1.49k stars 78 forks source link

Lifecycle methods #31

Closed Madumo closed 6 years ago

Madumo commented 7 years ago

Like we talked on issue #27, there is no real lifecycle hooks right now. I just added some:

beforeUpdate and afterUpdate are both called with the update data.

antonmedv commented 7 years ago

Like this, but what is impact on perf? Calling a lot of noop? Also we need docs for this stuff.

Madumo commented 7 years ago

For the noop, the jit normally see that the function call does nothing and remove it. It is actually faster than if (thereIsAFunction) { callFunction(); }. In fact, some other parts of monkberry could also benefit from this, but that was not the point of the PR.

source (see part 3)

Madumo commented 7 years ago

I just found out that this build sometime throw the Can not insert child view into parent node. You need append your view first and then update. error when inserting a comment node. I will look into that and come back with a fix and proper documentation.

antonmedv commented 7 years ago

Okay.

Madumo commented 7 years ago

Oh nevermind about the error, it was because of something else in my app, not because of that patch.

antonmedv commented 6 years ago

@Madumo sorry for delay) Now I'm working on v5 with full lifecycle events (see next branch)