How to use the wonka.scan 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 / hooks / useSubscription.ts View on Github external
pipe(
              subscription$,
              map(({ stale, data, error, extensions }) => ({
                fetching: true,
                stale: !!stale,
                data,
                error,
                extensions,
              }))
            ),
            // When the source proactively closes, fetching is set to false
            fromValue({ fetching: false }),
          ]);
        }),
        // The individual partial results are merged into each previous result
        scan((result, partial: any) => {
          const { current: handler } = handlerRef;
          // If a handler has been passed, it's used to merge new data in
          const data =
            partial.data !== undefined
              ? typeof handler === 'function'
                ? handler(result.data, partial.data)
                : partial.data
              : result.data;
          return { ...result, stale: false, ...partial, data };
        }, initialState)
      ),
    useMemo(() => (args.pause ? null : makeSubscription$()), [
github FormidableLabs / urql / src / hooks / useQuery.ts View on Github external
pipe(
              query$,
              map(({ stale, data, error, extensions }) => ({
                fetching: false,
                stale: !!stale,
                data,
                error,
                extensions,
              }))
            ),
            // When the source proactively closes, fetching is set to false
            fromValue({ fetching: false }),
          ]);
        }),
        // The individual partial results are merged into each previous result
        scan(
          (result, partial) => ({ ...result, stale: false, ...partial }),
          initialState
        )
      ),
    useMemo(() => (args.pause ? null : makeQuery$()), [args.pause, makeQuery$]),