[wp-trac] [WordPress Trac] #38728: Prevent previewer becoming frozen when refreshing too fast

WordPress Trac noreply at wordpress.org
Wed Nov 9 10:40:49 UTC 2016


#38728: Prevent previewer becoming frozen when refreshing too fast
--------------------------+------------------------------
 Reporter:  nikeo         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Customize     |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by nikeo):

 '''A few details about the technical choice :'''
 At first using an `api.state` Value, like `api.state( 'refreshing')`,
 seemed to be appropriate since the pupose of this fix is to listen to the
 ''refresh in progress'' state of the api. But it appeared that the
 synchronous approach did not work in this particular case.
 That's why I've chosen the asynchronous `$.Deferred()` way.

 I was also thinking to include this deferred in the list of
 `api._deferreds` first. But then I realized that `api._deferreds` was not
 necessarily designed for this. Right now it's used by the background_image
 control only.

 '''Side note :'''
 Another possible improvement I've discovered while working on the refresh
 process would be to make it return a `promise()` object. This refresh
 promise would be resolve() in the `onceSynced()` function.
 This way, it would be possible to use the following kind of syntax to fire
 an action on demand after a specific refresh().


 {{{
 api.previewer.refresh().done( function() {
  //fire actions after a specific refresh, when the preview is ready and
 synced
 } );

 }}}


 Because right now, we can add callbacks to the `'synced'` previewer event,
 but it will be fired after on all refresh calls, with no possibility to
 target a specific refresh that should be followed by a custom action.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38728#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list