import { checkObservable } from "./_check" import { Source } from "./_core" import { In, Out } from "./_interfaces" import { EventStream, EventStreamDispatcher, isEventStream } from "./EventStream" import { Observable } from "./Observable" import { isProperty, Property, PropertyDispatcher } from "./Property" export function makeObservable>( parent: In, source: Source, ): Out { checkObservable(parent) return (isProperty(parent) ? makeProperty(source) : makeEventStream(source)) as any } export function makeEventStream(source: Source): EventStream { return new EventStream(new EventStreamDispatcher(source)) } export function makeProperty(source: Source): Property { return new Property(new PropertyDispatcher(source)) } /** * Test whether the given value is Francis observable or not * @param x - Value to be tested * @returns `true` if value extends observable, otherwise `false` * @public */ export function isObservable(x: any): x is Observable { return isEventStream(x) || isProperty(x) }