4 changed files with 52 additions and 24 deletions
@ -1,37 +1,21 @@ |
|||||
// @flow
|
// @flow
|
||||
|
|
||||
import type { AccountRaw } from '@ledgerhq/live-common/lib/types' |
import type { AccountRaw } from '@ledgerhq/live-common/lib/types' |
||||
|
import { fromPromise } from 'rxjs/observable/fromPromise' |
||||
|
|
||||
import { createCommand, Command } from 'helpers/ipc' |
import { createCommand, Command } from 'helpers/ipc' |
||||
import { Observable } from 'rxjs' |
|
||||
import { syncAccount } from 'helpers/libcore' |
import { syncAccount } from 'helpers/libcore' |
||||
|
import withLibcore from 'helpers/withLibcore' |
||||
|
|
||||
type Input = { |
type Input = { |
||||
|
core: Object, |
||||
rawAccount: AccountRaw, |
rawAccount: AccountRaw, |
||||
} |
} |
||||
|
|
||||
type Result = AccountRaw |
type Result = AccountRaw |
||||
|
|
||||
const cmd: Command<Input, Result> = createCommand( |
const cmd: Command<Input, Result> = createCommand('libcoreSyncAccount', ({ rawAccount }) => |
||||
'accounts', |
fromPromise(withLibcore(core => syncAccount({ rawAccount, core }))), |
||||
'libcoreSyncAccount', |
|
||||
({ rawAccount }) => |
|
||||
Observable.create(o => { |
|
||||
// TODO scanAccountsOnDevice should directly return a Observable so we just have to pass-in
|
|
||||
syncAccount({ rawAccount }).then( |
|
||||
() => { |
|
||||
o.complete() |
|
||||
}, |
|
||||
e => { |
|
||||
o.error(e) |
|
||||
}, |
|
||||
) |
|
||||
|
|
||||
function unsubscribe() { |
|
||||
// FIXME not implemented
|
|
||||
} |
|
||||
|
|
||||
return unsubscribe |
|
||||
}), |
|
||||
) |
) |
||||
|
|
||||
export default cmd |
export default cmd |
||||
|
Loading…
Reference in new issue