Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Sink type from relay-runtime #4516

Closed
wants to merge 1 commit into from

Conversation

jaroslav-kubicek
Copy link
Contributor

I want to suggest exporting Sink & Source types so they can be used to type the argument of Observable.create, e.g. something like this:

import { Observable } from 'relay-runtime';

const responseHandler = () => {} // Here I would like to use either Source or Sink types

export const createRequestHandler =
  (customFetcher: Fetcher) =>
  (request: RequestParameters, variables: Variables, cacheConfig: CacheConfig) => {
    const observable = Observable.create(sink => {
      void customFetcher(request, variables, cacheConfig)
        .then(responseHandler(sink))
        .catch((error: Error) => {
          sink.error(error);
        })
        .then(() => {
          sink.complete();
        });
    });

    return observable;
  };

@facebook-github-bot
Copy link
Contributor

@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@alunyov merged this pull request in 5c7555b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants