How to use the wonka.makeSubject function in wonka

To help you get started, we’ve selected a few wonka examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FormidableLabs / urql / src / client.ts View on Github external
constructor(opts: ClientOptions) {
    this.url = opts.url;
    this.fetchOptions = opts.fetchOptions;
    this.fetch = opts.fetch;
    this.suspense = !!opts.suspense;
    this.requestPolicy = opts.requestPolicy || 'cache-first';

    // This subject forms the input of operations; executeOperation may be
    // called to dispatch a new operation on the subject
    const [operations$, nextOperation] = makeSubject();
    this.operations$ = operations$;

    // Internally operations aren't always dispatched immediately
    // Since exchanges can dispatch and reexecute operations themselves,
    // if we're inside an exchange we instead queue the operation and flush
    // them in order after
    const queuedOperations: Operation[] = [];
    let isDispatching = false;

    this.dispatchOperation = (operation: Operation) => {
      if (!isDispatching) {
        isDispatching = true;
        let queued;
        while ((queued = queuedOperations.shift()) !== undefined)
github FormidableLabs / urql / src / components / client.ts View on Github external
constructor(props) {

    if (
      process.env.NODE_ENV !== 'production' &&
      props.subscription &&
    ) {
      throw new Error(
        'You instantiated an Urql Client component with a subscription but forgot an updateSubscription prop. updateSubscription callbacks are required to work with subscriptions.'

    const [queryProp$, nextQueryProp] = makeSubject();
    const [
    ] = makeSubject();
    this.nextQueryProp = nextQueryProp;
    this.nextSubscriptionProp = nextSubscriptionProp;

    const queryResults$ = makeQueryResults$(props.client, queryProp$);
    const subscriptionResults$ = makeSubscriptionResults$(

    const [queryTeardown] = pipe(