Star

Created With

linknext() operator

Will pass the incoming request to the next matching request handler:

1import { next } from 'rxxpress';

2

3router.all('/')

4.pipe(

5 validate(({req}) => !!req.query.token), // --> check if there is a token on request

6 next() // --> go to next handler

7).subscribe();

8

9router.get('/')

10.pipe(respond(({req}) => `GET ${req.query.token}`))

11.subscribe();

12

13router.post('/')

14.pipe(respond(({req}) => `POST ${req.query.token}`))

15.subscribe();


linkSafety

By default, next() operates in safe mode, which means it only passes the request to next handler IF the request is not responded to:

1router.get('/:name')

2.pipe(

3 tap(({req, res}) => { // --> if it is dude, then respond

4 if (req.params.name === 'dude') res.send('Yo Dude!'); // --> if it is dude, then respond

5 }), // --> if it is dude, then respond

6 next() // --> its not dude? go to next handler

7).subscribe();

8

9router.get('/:name')

10.pipe(respnd(() => 'I do not know you mate')) // --> we only recognize the dude!

11.subscribe();

You can safe mode off by providing a parameter to next():

1router.get(...)

2.pipe(

3 ...

4 next(false) // --> pass incoming request to next handler even if it is already responded to

5)

6.subscribe();


linkPacket Flow

next() will NOT pass incoming packets down the observable sequence:

1router.get('/')

2.pipe(

3 next(),

4 tap(() => console.log('Got Here!')) // --> YOU WILL NEVER GET HERE!

5)

6.subscribe();

In this example, you will never get to the console log.

next() operatorSafetyPacket Flow

Home Router

Operatorschevron_right

Error Handling