Skip to content

Commit 85900cb

Browse files
committed
feat(plugin): plugin.quests api
* getQuests(): get the cached quests * update(): fetch, update quests and return quest list
1 parent d3a50da commit 85900cb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/base/plugin/quests.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import wrap from '../../utils/2.pokemon.js';
2+
import { registerModule } from '../../utils/plugin.js';
3+
import { getQuests, fetch } from '../../utils/quests.js';
4+
5+
wrap(() => {
6+
const name = 'quests';
7+
function mod(plugin) {
8+
return {
9+
getQuests,
10+
update(event = false) {
11+
return new Promise((res, rej) => {
12+
fetch(({ error, ...rest }) => {
13+
if (error) {
14+
rej(error);
15+
} else {
16+
res({ ...rest });
17+
}
18+
}, event);
19+
});
20+
},
21+
};
22+
}
23+
24+
registerModule(name, mod);
25+
});

0 commit comments

Comments
 (0)