Skip to content

Commit

Permalink
fix(helpers): get initial config
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed May 6, 2018
1 parent 6df378a commit a221bc7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/_helpers/config-manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppConfig, appConfigFactory } from '@/app-config'
import { storage, StorageListenerCb, StorageUpdate } from './browser-api'
import { map, filter } from 'rxjs/operators'
import { Observable } from 'rxjs'
import { Observable, from, concat } from 'rxjs'

export type AppConfigChanged = {
config: {
Expand Down Expand Up @@ -32,9 +32,12 @@ export function addAppConfigListener (cb: StorageListenerCb): void {
* Get AppConfig and create a stream listening config changing
*/
export function createAppConfigStream (): Observable<AppConfig> {
return storage.createStream<AppConfig>('config').pipe(
filter((config): config is StorageUpdate<AppConfig> => Boolean(config.newValue)),
map(config => config.newValue),
return concat(
from(getAppConfig()),
storage.createStream<AppConfig>('config').pipe(
filter((config): config is StorageUpdate<AppConfig> => Boolean(config.newValue)),
map(config => config.newValue),
),
)
}

Expand Down

0 comments on commit a221bc7

Please sign in to comment.