1.3.15 • Published 2 years ago

@bbp/nexus-link v1.3.15

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
2 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

2 years ago

1.3.14

2 years ago

1.3.15

2 years ago

1.3.12

2 years ago

1.3.11

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago