1.3.15 • Published 3 years ago

@bbp/nexus-link v1.3.15

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
3 years ago

Utilities for creating links 🔗.

Links are sort of middlewares, they allow us to control a request flow.

A link receives a request and pass it forward to the next link, unless it is a "terminating" link, in this case, the link does something of that request, for example sends it to the server.

A link returns an observable for the previous link to subscribe to.

The flow looks like:

request  -> | LINK1 | -> | LINK2 | -> server   |
response <- |       | <- |       | <- result <-|

Example:

A Link for logging how long it took to resolve the request, called logger

request  -> logger creates start=Date.now()   -> forward to next and subscribe -> request goes to server  |
response <- logger does log(Date.now()-start) <- bubble the chain of handlers  <- response from server  <-|

There are 2 types of Links:

  • stateless
  • stateful

A little bit like a react component can be:

const myComponent: React.FunctionComponent = () => <p>Hello</p>;

or

class MyComponent extends React.Component {
  render() {
    return <p>Hello</p>;
  }
}

A Link can be

const link: Link = (operation: Operation, forward: Link) => forward(operation);

or

class MyLink extends StatefulLink {
  request(operation: Operation, forward: NextLink) {
    return forward(operation);
  }
}

Documentation

some links

setMethod link that sets the method of the request (GET, POST, etc...)

poll link that polls every x seconds

triggerFetch (terminal link)

utils

concat concat 2 links together

pipe compose all links into 1

toLink transforms a stateless link into a stateful link

toPromise transform an observable into a promise

1.3.13

4 years ago

1.3.14

4 years ago

1.3.15

3 years ago

1.3.12

4 years ago

1.3.11

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago