Skip to content

Commit

Permalink
fix: Added isResolved, onResolved and onUpdated API hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Mar 5, 2024
1 parent dfd8e08 commit 8d3b1e9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Component } from "obsidian";
import type { HomebrewCreature } from "obsidian-overload";
import { Bestiary } from "src/bestiary/bestiary";
import type StatBlockPlugin from "src/main";
import { buildLoader } from "src/util";
import StatBlockRenderer from "src/view/statblock";
declare global {
interface Window {
Expand Down Expand Up @@ -78,6 +79,25 @@ export class API {
getCreatureFromBestiary(name: string): Partial<Monster> | null {
return Bestiary.getCreatureFromBestiarySync(name);
}
/**
* Retrieve a fully defined creature out of the bestiary, resolving all extensions.
*
* @param {string} name Name of the creautre to retrieve.
* @returns {Partial<Monster> | null} The creature from the bestiary, or null if not present.
*/
async getCreature(name: string): Promise<Partial<Monster> | null> {
return await Bestiary.getCreatureFromBestiary(name);
}

isResolved(): boolean {
return Bestiary.isResolved();
}
onResolved(callback: () => void) {
Bestiary.onResolved(callback);
}
onUpdated(callback: () => void) {
Bestiary.onUpdated(callback);
}

render(
creature: HomebrewCreature,
Expand Down

0 comments on commit 8d3b1e9

Please sign in to comment.