@children-of-atom/reactive-api
v0.2.1
Published
Svelte stores wrapping Atom/Pulsar's JavaScript API
Downloads
467
Readme
reactive-api
Svelte stores wrapping Pulsar's JavaScript API. Each store subscribes to the relevant Pulsar events and re-emits whenever the underlying data changes, so your components stay in sync without any manual wiring.
Installation
npm i @children-of-atom/reactive-apiUsage
Commands
import { getCommands, type Command } from '@children-of-atom/reactive-api/commands';getCommands(target?)
Returns a readable store containing all commands registered for a given target element, sorted by display name. The store updates whenever a package is activated or deactivated.
| Argument | Type | Description |
|---|---|---|
| target | HTMLElement \| undefined | Element to scope command lookup to. Omit to use the workspace root view. |
<script>
import { getCommands } from '@children-of-atom/reactive-api/commands';
const commands = getCommands();
</script>
{#each $commands as cmd}
<div>{cmd.displayName}</div>
{/each}Command type
Re-exported from @pulsar-edit/types as ReturnType<CommandRegistry['findCommands']>[number]:
type Command = {
name: string;
displayName: string;
description?: string;
tags?: string[];
};Config
import { config, schema, sources } from '@children-of-atom/reactive-api/config';All three are Readable stores that update on any config change and on package activation/deactivation.
| Export | Wraps |
|---|---|
| config | atom.config.getAll('') — the full merged config object |
| schema | atom.config.getSchema('*') — the full config schema |
| sources | atom.config.getSources() — ordered list of config sources |
<script>
import { config } from '@children-of-atom/reactive-api/config';
</script>
<pre>{JSON.stringify($config, null, 2)}</pre>Notifications
import {
notifications,
} from '@children-of-atom/reactive-api/notifications';A Readable store that updates when notifications are created or dismissed.
<script>
import { notifications } from '@children-of-atom/reactive-api/notifications';
</script>
<ul>
{#each $notifications as notification}
<li>{notification.message}</li>
{/each}
</ul>Packages
import {
activePackages,
bundledActivePackages,
loadedPackages,
bundledLoadedPackages,
} from '@children-of-atom/reactive-api/packages';All four are Readable stores that update on package activation/deactivation. Packages are sorted alphabetically by name.
| Export | Description |
|---|---|
| activePackages | All currently active packages |
| bundledActivePackages | Active packages that are bundled with Pulsar |
| loadedPackages | All loaded packages (including inactive) |
| bundledLoadedPackages | Loaded packages that are bundled with Pulsar |
<script>
import { activePackages } from '@children-of-atom/reactive-api/packages';
</script>
<ul>
{#each $activePackages as pkg}
<li>{pkg.name}</li>
{/each}
</ul>License
This work is licensed under The MIT License.
