mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 10:21:53 +00:00
feat(client): remove data mutation (#32)
* feat(client): remove data mutation * chore: address comments and fix some other issues * chore: send the most recent cache upon subscription
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
import { Update } from "../types";
|
||||
import { Source } from "./source";
|
||||
import { RPCResponse } from "./ws-source";
|
||||
import { Observable } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
import { Update } from '../types'
|
||||
import { Source } from './source'
|
||||
import { RPCResponse } from './ws-source'
|
||||
|
||||
export class MockSource<T> implements Source<T> {
|
||||
constructor(private readonly seed: Observable<Update<T>>) {}
|
||||
constructor (private readonly seed: Observable<Update<T>>) { }
|
||||
|
||||
watch$(): Observable<RPCResponse<Update<T>>> {
|
||||
return this.seed.pipe(map((result) => ({ result, jsonrpc: "2.0" })));
|
||||
watch$ (): Observable<RPCResponse<Update<T>>> {
|
||||
return this.seed.pipe(map((result) => ({ result, jsonrpc: '2.0' })))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BehaviorSubject, concat, from, Observable, of, Subject } from 'rxjs'
|
||||
import { BehaviorSubject, concat, from, Observable, of } from 'rxjs'
|
||||
import { concatMap, delay, map, skip, switchMap, take, tap } from 'rxjs/operators'
|
||||
import { Store } from '../store'
|
||||
import { Http, Update } from '../types'
|
||||
|
||||
@@ -43,14 +43,6 @@ export interface RPCError extends RPCBase {
|
||||
}
|
||||
export type RPCResponse<T> = RPCSuccess<T> | RPCError
|
||||
|
||||
function isRpcError<Error, Result> (arg: { error: Error } | { result: Result}): arg is { error: Error } {
|
||||
return !!(arg as any).error
|
||||
}
|
||||
|
||||
function isRpcSuccess<Error, Result> (arg: { error: Error } | { result: Result}): arg is { result: Result } {
|
||||
return !!(arg as any).result
|
||||
}
|
||||
|
||||
class RpcError {
|
||||
code: number
|
||||
message: string
|
||||
@@ -61,4 +53,4 @@ class RpcError {
|
||||
this.message = e.message
|
||||
this.details = e.data.details
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user