Skip to content

Commit

Permalink
fix(helpers): fix wrong deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Apr 17, 2018
1 parent a18f773 commit a55c46d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/_helpers/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AppConfig, appConfigFactory } from '@/app-config'
import { storage, StorageListenerCb } from './browser-api'
import { map } from 'rxjs/operators'
import { Observable } from 'rxjs/Observable'
import { fromPromise } from 'rxjs/observable/fromPromise'
import { concat } from 'rxjs/observable/concat'

export type AppConfigChanged = {
config: {
Expand All @@ -28,8 +30,14 @@ export function addAppConfigListener (cb: StorageListenerCb): void {
return storage.sync.addListener('config', cb)
}

/**
* Get AppConfig and create a stream listening config changing
*/
export function createAppConfigStream (): Observable<AppConfig> {
return storage.createStream<AppConfigChanged>('config').pipe(map(x => x.config.newValue))
return concat<AppConfig>(
fromPromise(getAppConfig()),
storage.createStream<AppConfigChanged>('config').pipe(map(x => x.config.newValue)),
)
}

export const appConfig = {
Expand Down

0 comments on commit a55c46d

Please sign in to comment.