Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@matchlighter/fetcher
Advanced tools
Awesome declarative data "fetchers" for Class-Based React Components.
Awesome declarative data "fetchers" for Class-Based React Components.
Fetcher leverages MobX
and @matchlighter/meta_components
to provide a clean, effective API.
NB: Be sure to decorate your Class Components with @with_meta_components
from @matchlighter/meta_components
.
@fetched(func: (params) => data, options?: { ... })
A basic fetcher that executes an async function when params change and sets the return value to the property.
The basic fetcher provides options for debouncing, throttling, polling and more. See the Type definitions for the options
parameter for details.
@api_fetched(url, transformer?: (response) => data, options?: { ... })
Fetcher
includes a pre-built @api_fetched
decorator that leverages Axios. @api_fetched
provides most of the same options that @fetched
does.
It may be used by decorating an accessor like so:
@with_meta_components // Note that this decoration is required. If using MobX, place it _above_ `@observer`.
class SomeComponent extends Component {
@api_fetched("api/v1/some_class/:id")
accessor api_result: ApiResultType;
}
It will automatically resolve :parameter
s in the URL string against a configurable set of sources. The default resolution order is as follows:
this
this.props
this.props.match.params
(Intended for use with React Router)config.token_context
@api_fetched
can be configured in a number of ways. This can be done like so:
import { config } from '@matchlighter/fetcher'
config.api.token_context = {}; // Provide a global data store for use when resolving `:parameter`s
config.api.backend = AxiosInstance; // Set the Axios Instance for use when making API calls
config.api.transform_response = (response) => transform_response; // Set a default response transformer
// Configure default options for `@api_fetched` Fetchers
config.api.defaults = {
// Any Option that can be passed to Axios can be included here as well.
...AxiosRequestConfig,
// Set the Request method that should be used
method: 'GET',
/* Action to take when a URL can't resolve all of its tokens.
* - 'skip' - Don't make the request
* - 'error' - Throw and Error
* - 'continue' - Make the request anyway, without substituting the token
* - May also be a function: (missingTokens: string[]) => MissingTokenAction
*/
missingTokens: 'skip',
/* May be a list of sources for token resolution, or a custom function.
* Function Signature: (token: string, extraParams, component) => string
* If an array is supplied, it may contain any of the following values:
* - `this` - The Component instance
* - `$token_context` - The global config.api.token_context object
* - `$params` - Fetcher-local Params
* - `$react_props` - React Props Hash
* - `$react_state` - React State Hash
* - `$route_params` - React Router route params
*/
resolveTokens: ['this', '$react_props', '$route_params', '$token_context'],
}
FAQs
Awesome declarative data "fetchers" for Class-Based React Components.
We found that @matchlighter/fetcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.