Skip to content

chain

chain<R, A, B>(f): (data) => Reader<R, B>

Defined in: Core/Reader.ts:99

Sequences two Readers. Both see the same environment. The output of the first is passed to f, which returns the next Reader.

R

A

B

(a) => Reader<R, B>

(data): Reader<R, B>

Reader<R, A>

Reader<R, B>

const buildUrl = (path: string): Reader<Config, string> =>
  Reader.asks(c => `${c.baseUrl}${path}`);

const addAuth = (url: string): Reader<Config, string> =>
  Reader.asks(c => `${url}?key=${c.apiKey}`);

pipe(
  buildUrl("/items"),
  Reader.chain(addAuth)
)(appConfig); // "https://api.example.com/items?key=secret"