• Nick Stenning's avatar
    Avoid double-binding event handlers for streamer reconnection · 12ff84a3
    Nick Stenning authored
    Using `$rootScope.$on` to bind event handlers in a controller is usually
    going to result in bugs, because:
    
    - The lifecycle of `$rootScope` is that of the entire application --
      that is, it never gets torn down.
    - The lifecycle of the controller depends on when and where that
      controller is instantiated. In our case, logging in and logging out of
      the application triggers a route reload[1], which tears down the
      WidgetController.
    - WidgetController has no ability to unbind event handlers when it is
      torn down.
    
    Luckily the fix is relatively straightforward. Because this event is
    `$broadcast` on the root scope, it propagates to all child scopes. Thus,
    we can listen to the event on the controller's local `$scope` and ensure
    that the handlers are garbage collected along with the scope when the
    controller is torn down.
    
    [1]: https://github.com/hypothesis/client/blob/d6a1392/h/static/scripts/app-controller.js#L71
    12ff84a3
Name
Last commit
Last update
..
integration Loading commit data...
annotation-fixtures.js Loading commit data...
annotation-mapper-test.js Loading commit data...
annotation-metadata-test.js Loading commit data...
annotation-sync-test.coffee Loading commit data...
annotation-ui-controller-test.js Loading commit data...
annotation-ui-sync-test.js Loading commit data...
annotation-ui-test.js Loading commit data...
annotation-viewer-controller-test.js Loading commit data...
app-controller-test.js Loading commit data...
auth-test.js Loading commit data...
bootstrap.js Loading commit data...
bridge-test.coffee Loading commit data...
build-thread-test.js Loading commit data...
cross-frame-test.coffee Loading commit data...
discovery-test.coffee Loading commit data...
drafts-test.js Loading commit data...
empty.html Loading commit data...
features-test.js Loading commit data...
form-respond-test.coffee Loading commit data...
groups-test.js Loading commit data...
host-test.coffee Loading commit data...
local-storage-test.coffee Loading commit data...
login-form-test.coffee Loading commit data...
markdown-commands-test.js Loading commit data...
media-embedder-test.js Loading commit data...
permissions-test.coffee Loading commit data...
promise-util.js Loading commit data...
raven-test.js Loading commit data...
render-markdown-test.js Loading commit data...
retry-util-test.js Loading commit data...
root-thread-test.js Loading commit data...
search-client-test.js Loading commit data...
search-filter-test.coffee Loading commit data...
session-test.js Loading commit data...
settings-test.js Loading commit data...
store-test.js Loading commit data...
stream-controller-test.coffee Loading commit data...
streamer-test.js Loading commit data...
tags-test.coffee Loading commit data...
time-test.js Loading commit data...
unicode-test.coffee Loading commit data...
util.js Loading commit data...
view-filter-test.coffee Loading commit data...
virtual-thread-list-test.js Loading commit data...
websocket-test.js Loading commit data...
widget-controller-test.js Loading commit data...