-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out PersistedState business logic from angular (#9687)
* - Remove angularization of PersistedState. - Provide the angularized version with PersistedStateProvider. - Use named exports - Es6-ify PersistedState class This pushes forward the first bullet point of #9686 * Address code review comments - Use single point of entry - Use injector instead of private - Use a new class (‘AngularizedPersistedState’) name instead of an arrow function * Remove extra import line
- Loading branch information
1 parent
6fd7280
commit 5f4cf32
Showing
23 changed files
with
185 additions
and
163 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './persisted_state.factory.js'; | ||
export { PersistedState } from './persisted_state.js'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @name AngularPersistedState | ||
* | ||
* Returns a PersistedState object which uses an EventEmitter instead of | ||
* the SimpleEmitter. The EventEmitter adds digest loops every time a handler is called | ||
* so it's preferable to use this variation when a callback modifies angular UI. | ||
* | ||
* TODO: The handlers themselves should really be responsible for triggering digest loops | ||
* as opposed to having an all or nothing situation. A nice goal would be to get rid | ||
* of the EventEmitter entirely and require handlers that need it to trigger a digest loop | ||
* themselves. We can even supply a service to wrap the callbacks in a function that | ||
* would call the callback, and finish with a $rootScope.$apply(). | ||
*/ | ||
|
||
import EventsProvider from 'ui/events'; | ||
import { PersistedState } from './persisted_state'; | ||
import uiModules from 'ui/modules'; | ||
|
||
const module = uiModules.get('kibana'); | ||
|
||
module.factory('PersistedState', ($injector) => { | ||
const Private = $injector.get('Private'); | ||
const Events = Private(EventsProvider); | ||
|
||
// Extend PersistedState to override the EmitterClass class with | ||
// our Angular friendly version. | ||
return class AngularPersistedState extends PersistedState { | ||
constructor(value, path, parent, silent) { | ||
super(value, path, parent, silent, Events); | ||
} | ||
}; | ||
}); | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.