Skip to content

Commit

Permalink
Add Flux stuff to cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite committed Jan 5, 2025
1 parent a2960ef commit d1f5d8e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/content/docs/ext-dev/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,28 @@ const { something } = spacepack.findByCode(...)[0].exports;
```

Remember to add your find to [your extension dependencies](/ext-dev/webpack#webpack-module-insertion) and [declare Spacepack as a dependency](#using-another-extension-as-a-library).

## Interacting with Flux events

```ts
import Dispatcher from "@moonlight-mod/wp/discord/Dispatcher";

// Listen for MESSAGE_CREATE events
Dispatcher.subscribe("MESSAGE_CREATE", (event: any) => {
console.log(event);
});

// Block all events (don't actually do this)
Dispatcher.addInterceptor((event) => {
console.log(event.type);
return true;
});
```

## Interacting with Flux stores

```ts
import { UserStore } from "@moonlight-mod/wp/common_stores";

console.log(UserStore.getCurrentUser());
```

0 comments on commit d1f5d8e

Please sign in to comment.