Announcement

Collapse
No announcement yet.

Question about program flow, beforeSave hook, afterSave hook and front end refreshing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • tothewine
    commented on 's reply
    Too bad shared hosts do not allow it often :\

  • yuri
    replied
    The best way it to use Websocket. You subscribe to a specific event on frontend. Backend triggers that event and frontend is notified immediately.

    Leave a comment:


  • telecastg
    replied
    Thanks tothewine I greatly appreciate the information.

    I had not considered a cron job but it is a possibility, specially if there are many functions that can be executed "in the background" without interrupting the rendering process.

    In the meantime, what I have done is taking advantage of ajax asyncrhonicity and making ajax calls for "time expensive" operations that are not directly related to the entity that I am working on.

    For example, we have a "Chat" entity where users can write posts about an entity (similar to stream), and when a post is created, the system notifies a defined group of users about the new post by email.

    Originally, I had created the send email instructions as part of an afterSave hook for the Chat entity, so as confirmed by your information, the front end was needlessly waiting for the back end to execute the email send commands before re-rendering the Chat.

    Now what I have done is to create a listener for the "after:save" event in the Chat detail view setup function and when the event is triggered an ajax call is made to an entry point that sends the email notifications without interrupting the front end rendering process.

    Leave a comment:


  • tothewine
    replied
    afaik it is refreshed when the php api request is finished and that should include all applicable hooks. for speedup i was thinking of an extension or something that executes an "afterSaveBackground" in a cron job afterwards

    Leave a comment:


  • Question about program flow, beforeSave hook, afterSave hook and front end refreshing

    Could anybody tell me if the front end is refreshed after the beforeSave hook is executed or does it wait until both beforeSave and afterSave hooks are executed ?

    I am trying to see if I can speed up the front end by better segmenting beforeSave and afterSave instructions.

    Thanks in advance
Working...
X