Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/core-abilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ Simply import the package to initialize the WordPress abilities:
import '@wordpress/core-abilities';
```

Initialization is asynchronous because categories and abilities are fetched from the REST API. To wait for registration to finish before calling `getAbilities()` or `executeAbility()`, await the exported `ready` promise:

```js
import { ready } from '@wordpress/core-abilities';
import { getAbilities, executeAbility } from '@wordpress/abilities';

await ready;

console.log( getAbilities() );
console.log( await executeAbility( 'core/get-site-info' ) );
```

## Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
Expand Down
4 changes: 2 additions & 2 deletions packages/core-abilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ async function initialize(): Promise< void > {
await initializeAbilities();
}

// Auto-initialize on import
initialize();
// Auto-initialize on import.
export const ready: Promise< void > = initialize();
Loading