Skip to content

Questions on callbacks #179

@Indigo744

Description

@Indigo744

Hey,

I was wondering regarding some callbacks we provide: afterInit, afterUpdate, afterShowRange
What is the purpose of using an "after" callback, instead of simply writing a function after the call? Since JS is sequential, this will work the same.

I can understand the need for afterInit and afterUpdate, they provide useful parameters (paper, areas...), even though these parameters are accessible through the Mapael object.

In any way, afterShowRange is useless in this current state.

I was thinking, maybe the callbacks should fire only when all animations (if there are animation of course) are finished? That way, the callback will have a more useful purpose.

Right now, the user doesn't have any information regarding when the animation are done. If a user wants to do something else, it would have to use a setTimeout() in order to wait for any animation to finish.

Actually, I was also thinking that any trigger function could return a promise (See the deferred object). That way, the user could write:

$(".mapael").trigger("update", opt).done(function(){
    // ... special processing executed only after all animations are done
});

What is your opinion on this?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions