mirror of
https://github.com/discourse/discourse.git
synced 2025-03-04 01:23:10 +08:00
Provide an option callback to the API
This commit is contained in:
parent
1145d204ed
commit
c6456f5c3e
@ -78,9 +78,18 @@ function getPluginApi(version) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function withPluginApi(version, cb) {
|
/**
|
||||||
|
* withPluginApi(version, apiCode, noApi)
|
||||||
|
*
|
||||||
|
* Helper to version our client side plugin API. Pass the version of the API that your
|
||||||
|
* plugin is coded against. If that API is available, the `apiCodeCallback` function will
|
||||||
|
* be called with the `PluginApi` object.
|
||||||
|
*/
|
||||||
|
export function withPluginApi(version, apiCodeCallback, opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
const api = getPluginApi(version);
|
const api = getPluginApi(version);
|
||||||
if (api) {
|
if (api) {
|
||||||
cb(api);
|
return apiCodeCallback(api);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user