Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@automattic/data-stores
Advanced tools
Readme
This package contains a collection of @wordpress/data
-based stores that can be used to fetch data from various WordPress.com REST API endpoints.
It is meant to be helpful for projects developed inside the Calypso monorepo that don't want to use Calypso's (monolithic) Redux state tree.
To use stores from the package, import and register the relevant store to obtain its key:
import { Verticals } from '@automattic/data-stores';
import { useSelect } from '@wordpress/data';
const VERTICALS_STORE = Verticals.register();
export const VerticalSelect = (): React.FunctionComponent< > => {
const verticals = useSelect( ( select ) => select( VERTICALS_STORE ).getVerticals() );
return (
<ul>
{ verticals.map( ( vertical ) => (
<li key={ vertical.vertical_id }>{ vertical.vertical_name }</li>
) ) }
</ul>
);
};
register
functionsStores are not registered in their module code. Instead, they expose register
functions. This is an important technical consideration to avoid side effects and allow tree-shaking.
When implementing a store, registration on evaluation should be avoided. Please, follow the pattern of exporting a register
function.
When an application needs to use a store that should be configured, it may be helpful to expose that store from a wrapper module:
// vertical-store.ts
import { DomainSuggestions } from '@automattic/data-stores';
export const DOMAIN_SUGGESTIONS_STORE = DomainSuggestions.register( {
/* …my application configuration… */
} );
// elsewhere…
import { DOMAIN_SUGGESTIONS_STORE } from './vertical-store';
select( DOMAIN_SUGGESTIONS_STORE ).getCategories();
The stores in this package are written in TypeScript, and type definitions are generated as part of the build process. Furthermore, we're injecting type information for available selectors and actions into the @wordpress/data
module, which means that you'll get handy autocomplete suggestions, if you're writing your project in TypeScript and you've enabled your editor's TypeScript feature or plugin.
FAQs
Calypso Data Stores.
The npm package @automattic/data-stores receives a total of 14,214 weekly downloads. As such, @automattic/data-stores popularity was classified as popular.
We found that @automattic/data-stores demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 37 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.