feat: Observable correction
This commit is contained in:
parent
30f215ee87
commit
4fede0db41
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Observer } from './Observer';
|
import { Observer } from './Observer';
|
||||||
|
import { Subscriber } from './Subscriber';
|
||||||
import { Subscription, TeardownLogic } from './Subscription';
|
import { Subscription, TeardownLogic } from './Subscription';
|
||||||
|
|
||||||
type SubscribeFunction<T> = (obs: Partial<Observer<T>>) => Subscription;
|
type SubscribeFunction<T> = (obs: Partial<Observer<T>>) => Subscription;
|
||||||
@ -21,13 +22,17 @@ export interface ObservableConstructor {
|
|||||||
* Implementation
|
* Implementation
|
||||||
*/
|
*/
|
||||||
export class Observable<T> implements IObservable<T> {
|
export class Observable<T> implements IObservable<T> {
|
||||||
constructor(subscriptionFactory: SubscriptionFactory<T>) {
|
constructor(private subscriptionFactory: SubscriptionFactory<T>) {}
|
||||||
void subscriptionFactory;
|
|
||||||
throw new Error('TODO');
|
|
||||||
}
|
|
||||||
|
|
||||||
subscribe(obs: Partial<Observer<T>>): Subscription {
|
subscribe(obs: Partial<Observer<T>>): Subscription {
|
||||||
void obs;
|
const subscriber = new Subscriber(obs);
|
||||||
throw new Error('TODO');
|
|
||||||
|
try {
|
||||||
|
subscriber.add(this.subscriptionFactory(subscriber));
|
||||||
|
} catch (e) {
|
||||||
|
subscriber.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return subscriber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user