Created
August 14, 2017 13:13
-
-
Save justinobney/2a79bd5ecf499d2ff8aa70fd9185f246 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AngularComponent { | |
static $inject = []; | |
constructor(...args) { | |
this.$inject = this.constructor.$inject.reduce( | |
(acc, injectName, index) => ({ | |
...acc, | |
[injectName]: args[index], | |
}), | |
{} | |
); | |
} | |
} | |
class Controller extends AngularComponent { | |
static $inject = ['$scope', 'eventBus', 'uiState']; | |
constructor(...args) { | |
super(...args); | |
// if you need other things here... | |
// if not, remove constructor... | |
} | |
$onInit() { | |
this.$inject.eventBus.register( | |
BROADCAST_EVENTS.CONNECTION_CHANGED, | |
this._onConnectionChange, | |
this.$inject.$scope | |
); | |
this.$inject.eventBus.register( | |
BROADCAST_EVENTS.SELECTED_TAKEOFF_UPDATED, | |
() => this._onConnectionChange(null, true), | |
this.$inject.$scope | |
); | |
} | |
_onConnectionChange = (e, connected) => { | |
this.$inject.uiState.syncConnecting = !connected; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment