src/cm/media/js/lib/yui/yui_3.10.3/releasenotes/HISTORY.event-custom.md
changeset 525 89ef5ed3c48b
equal deleted inserted replaced
524:322d0feea350 525:89ef5ed3c48b
       
     1 Custom Event Infrastructure Change History
       
     2 ==========================================
       
     3 
       
     4 3.10.3
       
     5 ------
       
     6 
       
     7 * No changes.
       
     8 
       
     9 3.10.2
       
    10 ------
       
    11 
       
    12 * Fixed issue with facade carrying stale data for the "no subscriber" case.
       
    13 
       
    14 * Fixed regression where `once()` and `onceAfter()` subscriptions using the
       
    15   `*` prefix threw a TypeError [#676]. `target.once('*:fooChange', callback)`
       
    16 
       
    17 * Fixed exception with fire(type, null) with emitFacade:true.
       
    18 
       
    19 3.10.1
       
    20 ------
       
    21 
       
    22 * No changes.
       
    23 
       
    24 3.10.0
       
    25 ------
       
    26 
       
    27 * Significant performance improvements in common CustomEvent operations.
       
    28 
       
    29   There are improvements across the board, but the work was largely aimed at events
       
    30   with no listeners (to facilate speeding up `new Base()` which publishes/fires 2
       
    31   events [init, initializedChange], which usually don't have listeners).
       
    32 
       
    33   For example, on Chrome:
       
    34 
       
    35       `fire() with 0 listeners` is 6 times faster
       
    36       `fire() with 2 listeners` is 2-3 times faster (w, w/o payload)
       
    37       `publish()` is 2 times faster
       
    38       `publish() compared to _publish()` is 5 times faster (see below)
       
    39       `EventTarget construction + publish + fire with 0 listeners` is 3 times faster
       
    40 
       
    41   Major performance related changes are listed below.
       
    42 
       
    43   Commit messages have detailed descriptions of incremental changes, and the
       
    44   benefits introduced.
       
    45 
       
    46 * Moved more properties to the `CustomEvent` prototype, to improve publish costs
       
    47 
       
    48 * Instantiate `_subscribers`, `_afters` arrays lazily to reduce publish costs for the
       
    49   no listener case. Same thing was also done for less commonly used features, like the
       
    50   `targets` map.
       
    51 
       
    52 * Reduce `new EventTarget` costs, by removing default properties which just match the
       
    53   `CustomEvent` defaults. It reduces the number of properties we need to iterate each time
       
    54   we mix values while publishing.
       
    55 
       
    56 * Removed unrequired `Y.stamp` on _yuievt. It wasn't being used in the library code base
       
    57 
       
    58 * Changed `Y.stamp` calls to `Y.guid` where it was being used to set up `id` properties.
       
    59   There didn't seem to be a need to add the `_yuid` property and it added overhead.
       
    60 
       
    61 * Provide a fast-track for `fire` with no potential subscribers (no local subscribers, no
       
    62   bubble targets, and no broadcast), by jumping to the default function directly (if
       
    63   configured) or just doing nothing, if no default function.
       
    64 
       
    65 * Made `*` support close to zero cost for folks who aren't using it, by only trying to look
       
    66   for siblings if someone had subscribed using `*`.
       
    67 
       
    68 * Reduced `isObject` checks, by combining facade creation and argument manipulation
       
    69   into `_getFacade()`.
       
    70 
       
    71 * Improved `fireComplex` times, by creating lesser used queues lazily (`es.queue`, `es.afterQueue`).
       
    72 
       
    73 * Avoid `slice` and related arguments iteration costs for common `fire` signatures,
       
    74   (`fire("foo")`, `fire("foo", {})`) by working with arguments directly for these cases.
       
    75 
       
    76   Since `fire` is open-ended in terms of it's number of args, anything besides the above
       
    77   signatures still use `slice`.
       
    78 
       
    79 * `fire(...)` now delegates to `_fire(array)` to avoid repeated conversion of `arguments` to
       
    80    arrays, across the calling stack from `eventTarget.fire()` to `customEvent.fire()`.
       
    81 
       
    82 * Avoid `_monitor()` hops, but checking for whether or not monitoring is enabled outside
       
    83   of the function.
       
    84 
       
    85 * Removed `Y.cached` wrapper around `_getType()`. This was an interesting one. The work
       
    86   we do to generate the key for the cache, turned out to be more than what `_getType()` costs
       
    87   if we just re-run it.
       
    88 
       
    89 * Added a fast-path *currently private* `_publish()` for low-level, critical path
       
    90   implementations, such as Attribute and Base.
       
    91 
       
    92   `_publish()` doesn't provide any API sugar (e.g. type to fulltype conversation), and
       
    93   leaves the `CustomEvent` configuration to the caller to avoid iteration and mixing costs.
       
    94 
       
    95   The assumption is that low-level callers know about the event system architecture, and
       
    96   know what they're doing. That's why its private for now, but its 5x faster than `publish()`
       
    97   for a comparable event configuration. `publish()` leverages `_publish()`, also ends up being
       
    98   faster after this change, but not by such a big factor.
       
    99 
       
   100 * Revert EventTarget back to lazily creating `targets`.
       
   101 
       
   102 3.9.1
       
   103 -----
       
   104 
       
   105 * No changes.
       
   106 
       
   107 3.9.0
       
   108 -----
       
   109 
       
   110 * No changes.
       
   111 
       
   112 3.8.1
       
   113 -----
       
   114 
       
   115 * No changes.
       
   116 
       
   117 3.8.0
       
   118 -----
       
   119 
       
   120   * No changes.
       
   121 
       
   122 3.7.3
       
   123 -----
       
   124 
       
   125 * No changes.
       
   126 
       
   127 3.7.2
       
   128 -----
       
   129 
       
   130 * No changes.
       
   131 
       
   132 3.7.1
       
   133 -----
       
   134 
       
   135 * No changes.
       
   136 
       
   137 3.7.0
       
   138 -----
       
   139 
       
   140  * CustomEvent run-time performance optimizations.
       
   141 
       
   142    a. [!] The `subscribers` and `afters` CustomEvent instance properties have
       
   143       been deprecated, and replaced with private arrays (instead of hashes).
       
   144 
       
   145       If you're referring to the `subscribers` or `afters` properties directly,
       
   146       you can set the `Y.CustomEvent.keepDeprecatedSubs` to true, to restore
       
   147       them, but you will incur a performance hit in doing so.
       
   148 
       
   149       The rest of the CustomEvent API is driven by the new private arrays, and
       
   150       does not require the `subscribers` and `afters` properties, so you should
       
   151       only enable `keepDeprecatedSubs` if your code is referring to the properties
       
   152       directly.
       
   153 
       
   154       If you are using the above properties directly, please file an enhancement
       
   155       request and we'll provide a public way to achieve the same results, without
       
   156       the performance hit before we remove the properties permanently.
       
   157 
       
   158    b. Avoid new EventTarget when stoppedFn is not used.
       
   159 
       
   160    c. Optimized mixing during the creation of a custom event object.
       
   161 
       
   162    d. Optimized mixing done on the facade, during a fire with payload.
       
   163 
       
   164    Performance results on Chrome 19/MacOS below, for the use case where we're
       
   165    iring with a payload:
       
   166 
       
   167    ## Custom Event Lifecycle Numbers (Fix a, b, c)
       
   168 
       
   169    BEFORE (3.6.0):
       
   170    EventTarget with attribute style publish, fire, with on/after listeners x 7,623 ops/sec
       
   171 
       
   172    CURRENT (With fixes a, b, c):
       
   173    EventTarget with attribute style publish, fire, with on/after listeners x 23,642 ops/sec
       
   174 
       
   175    ## Payload Numbers (Fix d)
       
   176 
       
   177    BEFORE (3.6.0):
       
   178    Fire With Payload - 10 listeners x 27,918 ops/sec ±1.32% (54 runs sampled)
       
   179 
       
   180    CURRENT (With fix d):
       
   181    Fire With Payload - 10 listeners x 63,362 ops/sec ±0.37% (58 runs sampled)
       
   182 
       
   183    The benchmark tests can be found in src/event-custom/tests/benchmark
       
   184 
       
   185    Log messages for the follow commits have more details:
       
   186 
       
   187    e7415e71decf3d921161e8883270e16b433aa150 - subscribers/afters fix.
       
   188    29f63996f8b69a7bb6d2e27f4d350c320998c0b2 - optimized payload mix fix.
       
   189 
       
   190  * CustomEvent memory optimizations.
       
   191 
       
   192    * Fixed `_facade` and `firedWith` which were holding onto a reference
       
   193      to the last fired event facade. Now `_facade` is reset to null after
       
   194      the fire sequence, and `firedWith` is only maintained for `fireOnce`
       
   195      CustomEvents. i
       
   196 
       
   197      This allows the facade from the last fired event to be GC'd whereas
       
   198      prior to this change it wasn't.
       
   199 
       
   200 3.6.0
       
   201 -----
       
   202 
       
   203  * Fixed memory consumption issue where Y.Do's internal touched object cache,
       
   204    Y.Do.objs, would never release object references.
       
   205 
       
   206    The Y.Do.objs property has been deprecated as of 3.6.0, and will be null.
       
   207 
       
   208    The cached state previously stored in Y.Do.objs has been moved onto the
       
   209    AOP'd object itself, in the *private* `_yuiaop` property.
       
   210 
       
   211    The only reason `_yuiaop` is mentioned here, is to provide a temporary
       
   212    migration path for users who may have been using Y.Do.objs. If you are using
       
   213    this property, please file a ticket with the use case, and we'll look at
       
   214    addressing the use case formally, while not impacting GC.
       
   215 
       
   216 3.5.1
       
   217 -----
       
   218 
       
   219   * No changes.
       
   220 
       
   221 3.5.0
       
   222 -----
       
   223 
       
   224   * Multiple calls to target.publish({ ... }) now work [Ticket #2531671]
       
   225 
       
   226 3.4.1
       
   227 -----
       
   228 
       
   229   * onceAfter (added in 3.4.0) now works for array and object signatures.
       
   230     [Ticket #2531121]
       
   231 
       
   232 3.4.0
       
   233 -----
       
   234 
       
   235   * Custom events published from `Y` no longer bubble by default.
       
   236 
       
   237 3.3.0
       
   238 -----
       
   239 
       
   240   * Undocumented and poorly named `each()` method on EventHandle changed to
       
   241     `batch()`.
       
   242 
       
   243   * After listeners for events fired in a `defaultFn` or listener are queued in
       
   244     the correct order.
       
   245 
       
   246   * Added `Y.Do.originalRetVal` and `Y.Do.currentRetVal` statics accessible by
       
   247     `Y.Do.after()` subscribers.
       
   248 
       
   249   * Exposed the previously private `EventTarget.parseType`.
       
   250 
       
   251 3.2.0
       
   252 -----
       
   253 
       
   254   * Fixed `defaultTargetOnly` publish configuration.
       
   255 
       
   256   * `detach()` now decrements `subCount`/`afterCount`.
       
   257 
       
   258   * Detaching via category no longer affects subscriptions on other objects.
       
   259 
       
   260 3.1.1
       
   261 -----
       
   262 
       
   263   * No changes.
       
   264 
       
   265 3.1.0
       
   266 -----
       
   267 
       
   268   * Wildcard prefix subscriptions supported: `target.on('*:click', …)` will be
       
   269     notified when `tree:click`, `tab:click`, etc are fired.
       
   270 
       
   271   * Added `EventTarget::once`, which is equivalent to `on()`, except the
       
   272     listener automatically detaches itself once executed.
       
   273 
       
   274   * Added event monitoring. When configured, an `EventTarget` will emit events
       
   275     for `publish()`, `attach()`, `fire()`, and `detach()` operations on the
       
   276     hosted events.
       
   277 
       
   278   * `EventTarget::on`'s `type` parameter is overloaded to accept arrays and
       
   279     objects for attaching multiple types at once.
       
   280 
       
   281   * `EventTarget::detach` returns the event target like the API docs already
       
   282     stated.
       
   283 
       
   284   * Events can now be configured to execute the `defaultFn` only on the targeted
       
   285     object, not on the bubble targets.
       
   286 
       
   287   * The event order has been reworked so that the after listeners for the entire
       
   288     event stack execute after all `defaultFn` across the entire bubble stack.
       
   289 
       
   290 3.0.0
       
   291 -----
       
   292 
       
   293   * Broken into core base and complex modules.
       
   294 
       
   295   * `broadcast` works for simple events.
       
   296 
       
   297   * If configured to return an `EventHandle`, the return value will always be a
       
   298     single object, regardless of how many listeners were attached. Previously,
       
   299     multiple listeners provided an array of detach handles.
       
   300 
       
   301 3.0.0beta1
       
   302 ----------
       
   303 
       
   304   * [!] Exposed methods are `on()` for the before moment, `after()` for the
       
   305     after moment, and `detach()` for unsubscribe. `subscribe()`, `before()`,
       
   306     `unsubscribe()`, and corresponding methods are deprecated.
       
   307 
       
   308   * Implemented the `broadcast` flag:
       
   309 
       
   310     * `broadcast = 1`: local, accessible via `Y.on('prefix:event')`.
       
   311     * `broadcast = 2`: global, accessible via `Y.on()` or globally via
       
   312       `Y.Global.on('prefix:event')`.
       
   313 
       
   314     Broadcast listeners cannot effect the `defaultFn` or host subscribers (so
       
   315     are in effect, after listeners), although this is still possible by added
       
   316     either `Y` or `Y.Global` as `EventTarget`s.
       
   317 
       
   318   * Moved `event-custom` out of `event` package.
       
   319 
       
   320   * `EventTarget` accepts a `prefix` configuration. This is used in all exposed
       
   321     methods to handle shortcuts to event names, e.g., `'click'` and
       
   322     `'menu:click'` are the same if the prefix is `'menu'`.
       
   323 
       
   324   * Event type accepts a event category which can be used to detach events:
       
   325 
       
   326         Y.on('category|prefix:event', fn);
       
   327         Y.detach('category|prefix:event');
       
   328         Y.detach('category|*');
       
   329 
       
   330   * Added `chain` config to events that makes the return value the event target
       
   331     rather than a detach handle. Use with the detach category prefix.
       
   332 
       
   333   * The `type` parameter can be an object containing multiple events to attach:
       
   334 
       
   335         Y.on({ 'event1': fn1, 'event2': fn2 });
       
   336 
       
   337   * `Y.fire` payload for event facades can be another facade or a custom event.