rxjs#Subscriber TypeScript Examples

The following examples show how to use rxjs#Subscriber. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts    From gnosis.1inch.exchange with MIT License 6 votes vote down vote up
public _subscribe(subscriber: Subscriber<T>): Subscription {
    // Hook into the subscribe method to trigger refreshing
    this._triggerProviderIfRequired();
    return super._subscribe(subscriber);
  }
Example #2
Source File: create-operator-function.ts    From s-libs with MIT License 6 votes vote down vote up
/**
 * Use this to create a complex pipeable operator. It is usually better style to compose existing operators than to create a brand new one, but when you need full control this can reduce some boilerplate.
 *
 * The supplied `subscriber` will act as a simple pass-through of all values, errors, and completion to `destination`. Modify it for your needs.
 *
 * A simple example, recreating the "map" operator:
 * ```ts
 * function map<I, O>(fn: (input: I) => O) {
 *   return createOperatorFunction<I, O>(
 *     (subscriber, destination) => {
 *       subscriber.next = (value) => {
 *         destination.next(fn(value));
 *       };
 *     },
 *   );
 * }
 * ```
 *
 * For a more complex example, check the source of `skipAfter`.
 */
export function createOperatorFunction<
  SourceType,
  DestinationType = SourceType,
>(
  modifySubscriber: (
    subscriber: RequiredSubscriber<SourceType>,
    destination: Observer<DestinationType>,
  ) => void,
): OperatorFunction<SourceType, DestinationType> {
  return (source: Observable<SourceType>): Observable<DestinationType> =>
    new Observable<DestinationType>((destination) => {
      const subscriber = new Subscriber<SourceType>(destination);
      modifySubscriber(subscriber, destination);
      return source.subscribe(subscriber);
    });
}
Example #3
Source File: store.ts    From s-libs with MIT License 5 votes vote down vote up
protected subscribers = new Map<Subscriber<T>, T | undefined>();
Example #4
Source File: runRequest.test.ts    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
subscriber: Subscriber<DataQueryResponse>;