4.1.1 • Published 6 months ago

mobx-requestor v4.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 months ago

mobx-requestor

What is this?

This is an abstraction over a resource request for mobx. It aims to make it simpler to deal with the data fetching and posting using any abstraction to perform the request/posts

How do I use it?

// simpler example
const rq = new MobxRequestor({
  call: (...args) => {
    // service.someMethod is just a function that returns a 
    // promise to resolve to the data being fetched or to 
    // the result of a POST/PUT/PATCH operation
    return service.someMethod(...args);
  }
});

// although this function return a promise
// it is guaranteed to always resolve 
// the data or error can be inspected on the 
// `error` and `response` properties respectively
await rq.execCall({ someArg: 1 });

// query the state of the request
rq.loading // true if the request is in progress

// if an error ocurred the error can be found here (as text)
rq.error

// if the request finalized without throwing then this will be true
rq.success

// whatever was resolved from the service.someMethod function 
// will be available in this property
req.response 

Building the repo

npm run build

Type-checking the repo

npm run type-check

And to run in --watch mode:

npm run type-check:watch

License

MIT

tests

TODO

4.1.1

6 months ago

4.1.0

12 months ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago