rebase-sdk
v0.0.41
Published
yarn:
Downloads
68
Readme
rebase-sdk
Usage
yarn:
yarn add rebase-sdk
npm:
npm install rebase-sdk
Integrate rebase's app/module into existing app page
- Publish your app/module in rebase.
- Set the app/module's access privilege as public.
- Add code in your existing app as below.
Import style
import "rebase-sdk/dist/style.css";
For react app:
import { LowcoderAppView } from "rebase-sdk";
<LowcoderAppView appId="{YOUR_APPLICATION_ID}" />;
LowcoderViewProps
| Name | Type | Description | Default value | |------------------------|-----------------------------|-----------------------------------------------------------------------------------------|---------------| | appId | string | The app's id in rebase. Required! | -- | | baseUrl | string | rebase's api base url | -- | | onModuleEventTriggered | (eventName: string) => void | Triggered when module's custom event is triggered. Works only when the app is a module. | -- | | onModuleOutputChange | (output: any) => void | Triggered when module's outputs change. Works only when the app is a module. | -- |
Invoke module methods
import { useRef } from "ref";
import { LowcoderAppView } from "rebase-sdk";
function MyExistingAppPage() {
const appRef = useRef();
return (
<div>
<LowcoderAppView appId={YOUR_APPLICATION_ID} ref={appRef} />;
<button onClick={() => appRef.current?.invokeMethod("some-method-name")}>
Invoke method
</button>
</div>
);
}
For vanilla js:
import { bootstrapAppAt } from "rebase-sdk";
const node = document.querySelector("#my-app");
async function bootstrap() {
const instance = await bootstrapAppAt(YOUR_APPLICATION_ID, node);
// set module inputs
instance.setModuleInputs({ input1: "xxx", input2: "xxx" });
// invoke module methods
instance.setModuleInputs({ input1: "xxx", input2: "xxx" });
// listen module event trigger
instance.on("moduleEventTriggered", (eventName) => {
console.info("event triggered:", eventName);
});
// listen module output change
instance.on("moduleOutputChange", (data) => {
console.info("output data:", data);
});
}