Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
errors$.onNext(error)
})
}
} else {
baseRef.child(location).set(value)
}
})
})
// Get an observable over the current uid of the user
let auth$ = authToObservable(baseRef)
let uid$ = auth$.map(x => x ? x.uid : null)
// Get an observable that will complete with one random ID
let pushId$ = Observable.create(observer => {
observer.onNext(pushId())
observer.onCompleted()
return () => {}
})
// Small utility to wrap objects in a 'set' object
let $set = object => {
return { $set: object }
}
// Prevents errors when getting using an empty path
let getFbChild = (ref, location) =>
location === `` ? ref : ref.child(location)
let specialCaseListeners = {
// Current user as observable
return (data) => Observable.create(obs => {
let cachedConsumerTag;
// generate unique ID for current transaction
const id = uuid.v4();
const topic = 'runner.result.' + id;
// return by type mapping
const returnByType = {
result: obs.onNext.bind(obs),
error: obs.onError.bind(obs),
done: obs.onCompleted.bind(obs),
};
const runCommand = async () => {
cachedConsumerTag = await service.subscribe(topic, (msg) => {
// log
logger.debug('[svc]: got message:', msg.type, 'for:', id);
// return depending on type
returnByType[msg.type](msg.data);
it("returns the rest of output as a second parameter stream", done => {
const [{listDecomposeLatest}] = TSERS({A: tsersDriver})
let n = 0
const sBy = val =>
O.of({key: "A", val: "a" + n + val}, {key: "B", val: "b" + n + val})
const in$ = O.create(o => {
n++
o.onNext([4, 1, 5])
setTimeout(() => {
n++
o.onNext([2, 5, 3])
}, 0)
})
const [_, rest$] = listDecomposeLatest(in$, sBy, "A")
rest$.should.be.instanceof(O)
rest$.bufferWithTime(100).first().subscribe(x => {
x.should.deepEqual([
{key: "B", val: "b14"},
{key: "B", val: "b11"},
{key: "B", val: "b15"},
{key: "B", val: "b22"},
function run(MD, main) {
let obs = null
const [out, loop] = main(MD(O.create(o => (obs = o) && (() => obs = null))))
return out.merge(loop.delay(0).filter(x => obs && obs.onNext(x) && false))
}
constructor() {
this.observable = Observable.create((observer: Observer) => {
this.observer = observer;
return () => { this.onDisconnect(); };
});
}
.flatMap(isCurrent => Observable.create((observer) => {
if (!isCurrent) {
require("rimraf")(dest, (err: any) => {
if (err) { observer.onError(err); return; }
delay(() =>
fs.mkdir(dest, (er) => {
if (er) { observer.onError(er); return; }
fs.writeFile(join(dest, ".version"), serverVersion, (e) => {
if (e) { observer.onError(e); return; }
observer.onNext(null);
observer.onCompleted();
});
}), 500);
});
return;
}
tail(): Observable {
return Observable.create(observer => {
try {
const cursor = this.mongodb.getOplog()
cursor.forEach(
(log: OpLog) => {
observer.onNext(log)
},
() => {
observer.onCompleted()
},
)
} catch (err) {
observer.onError(err)
}
})
}
export function ifEmpty(observable: Observable, other: Observable) {
return Observable.create(observer => {
var hasValue = false;
var cd = new CompositeDisposable();
cd.add(observable.subscribe(
value => {
hasValue = true;
observer.onNext(value);
},
e => observer.onError(e),
() => {
if (!hasValue) {
cd.add(other.subscribe(
value => observer.onNext(value),
e => observer.onError(e),
() => observer.onCompleted()
));
} else {
export default function makeRequest(config) {
if (!backendSet && !mockRequests) throw new Error('Must define a websocket backend');
return Observable.create((observer) => {
let request = generateRequestObject(defaultHeaders)(config);
prepareRequest(observer, request);
})
}
export function use() {
return Observable.create((observer) => {
let defaultMiddleware = useMiddlewareQueue.pop();
useMiddlewareQueue.push(observer);
useMiddlewareQueue.push(defaultMiddleware);
});
}