How to use the wonka.tap 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 / exchanges / debug.ts View on Github external
return ops$ =>
      pipe(
        ops$,
        // eslint-disable-next-line no-console
        tap(op => console.log('[Exchange debug]: Incoming operation: ', op)),
        forward,
        tap(result =>
          // eslint-disable-next-line no-console
          console.log('[Exchange debug]: Completed operation: ', result)
        )
      );
  }
github FormidableLabs / urql / src / exchanges / debug.ts View on Github external
return ops$ =>
      pipe(
        ops$,
        // eslint-disable-next-line no-console
        tap(op => console.log('[Exchange debug]: Incoming operation: ', op)),
        forward,
        tap(result =>
          // eslint-disable-next-line no-console
          console.log('[Exchange debug]: Completed operation: ', result)
        )
      );
  }
github FormidableLabs / urql / src / exchanges / ssr.ts View on Github external
// NOTE: Since below we might delete the cached entry after accessing
    // it once, cachedOps$ needs to be merged after forwardedOps$
    let cachedOps$ = pipe(
      sharedOps$,
      filter(op => isCached(op)),
      map(op => {
        const serialized = data[op.key];
        return deserializeResult(op, serialized);
      })
    );

    if (!isClient) {
      // On the server we cache results in the cache as they're resolved
      forwardedOps$ = pipe(
        forwardedOps$,
        tap((result: OperationResult) => {
          const { operation } = result;
          if (!shouldSkip(operation)) {
            const serialized = serializeResult(result);
            data[operation.key] = serialized;
          }
        })
      );
    } else {
      // On the client we delete results from the cache as they're resolved
      cachedOps$ = pipe(
        cachedOps$,
        tap((result: OperationResult) => {
          delete data[result.operation.key];
        })
      );
    }
github FormidableLabs / urql / src / exchanges / dedup.ts View on Github external
return ops$ => {
    const forward$ = pipe(
      ops$,
      filter(filterIncomingOperation)
    );
    return pipe(
      forward(forward$),
      tap(afterOperationResult)
    );
  };
};
github FormidableLabs / urql-devtools / src / exchange / exchange.ts View on Github external
return ops$ => {
    return pipe(
      ops$,
      map(addOperationContext),
      tap(handleOperation),
      forward,
      map(addOperationResponseContext),
      tap(handleOperation)
    );
  };
};
github FormidableLabs / urql-devtools / src / exchange / exchange.ts View on Github external
return ops$ => {
    return pipe(
      ops$,
      map(addOperationContext),
      tap(handleOperation),
      forward,
      map(addOperationResponseContext),
      tap(handleOperation)
    );
  };
};
github FormidableLabs / urql / src / exchanges / populate.ts View on Github external
return ops$ => {
    return pipe(
      ops$,
      tap(handleIncomingQuery),
      tap(handleIncomingTeardown),
      map(handleIncomingMutation),
      forward
    );
  };
};
github FormidableLabs / urql / src / exchanges / cache.ts View on Github external
const forwardedOps$ = pipe(
      merge([
        pipe(
          sharedOps$,
          filter(op => !shouldSkip(op) && !isOperationCached(op)),
          map(mapTypeNames)
        ),
        pipe(
          sharedOps$,
          filter(op => shouldSkip(op))
        ),
      ]),
      map(op => addMetadata(op, { cacheOutcome: 'miss' })),
      forward,
      tap(response => {
        if (
          response.operation &&
          response.operation.operationName === 'mutation'
        ) {
          handleAfterMutation(response);
        } else if (
          response.operation &&
          response.operation.operationName === 'query'
        ) {
          handleAfterQuery(response);
        }
      })
    );

    return merge([cachedOps$, forwardedOps$]);
  };
github FormidableLabs / urql / src / exchanges / populate.ts View on Github external
return ops$ => {
    return pipe(
      ops$,
      tap(handleIncomingQuery),
      tap(handleIncomingTeardown),
      map(handleIncomingMutation),
      forward
    );
  };
};