0.0.115 • Published 1 year ago
stitch-sdk v0.0.115
stitch-sdk
Usage
yarn:
yarn add stitch-sdk
npm:
npm install stitch-sdk
Integrate Stitch's app/module into existing app page
- Publish your app/module in Stitch.
- Set the app/module's access privilege as public.
- Add code in your existing app as below.
Import style
import "stitch-sdk/dist/style.css";
For react app:
import { StitchAppView } from "stitch-sdk";
<StitchAppView appId="{YOUR_APPLICATION_ID}" />;
StitchViewProps
Name | Type | Description | Default value |
---|---|---|---|
appId | string | The app's id in Stitch. Required! | -- |
baseUrl | string | Stitch's api base url | https://api.openblocks.dev |
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 { StitchAppView } from "stitch-sdk";
function MyExistingAppPage() {
const appRef = useRef();
return (
<div>
<StitchAppView appId={YOUR_APPLICATION_ID} ref={appRef} />;
<button onClick={() => appRef.current?.invokeMethod("some-method-name")}>
Invoke method
</button>
</div>
);
}
For vanilla js:
import { bootstrapAppAt } from "stitch-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);
});
}
0.0.115
1 year ago
0.0.114
1 year ago
0.0.113
1 year ago
0.0.112
1 year ago
0.0.111
1 year ago
0.0.110
1 year ago
0.0.96
1 year ago
0.0.97
1 year ago
0.0.98
1 year ago
0.0.99
1 year ago
0.0.101
1 year ago
0.0.100
1 year ago
0.0.95
1 year ago
0.0.90
1 year ago
0.0.91
1 year ago
0.0.92
1 year ago
0.0.93
1 year ago
0.0.94
1 year ago
0.0.89
1 year ago
0.0.84
1 year ago
0.0.85
1 year ago
0.0.86
1 year ago
0.0.87
1 year ago
0.0.88
1 year ago
0.0.80
1 year ago
0.0.81
1 year ago
0.0.82
1 year ago
0.0.83
1 year ago
0.0.77
1 year ago
0.0.78
1 year ago
0.0.79
1 year ago
0.0.62
2 years ago
0.0.63
2 years ago
0.0.64
2 years ago
0.0.65
2 years ago
0.0.66
2 years ago
0.0.67
2 years ago
0.0.68
2 years ago
0.0.60
2 years ago
0.0.61
2 years ago
0.0.59
2 years ago
0.0.73
2 years ago
0.0.74
2 years ago
0.0.75
2 years ago
0.0.76
2 years ago
0.0.57
2 years ago
0.0.58
2 years ago
0.0.70
2 years ago
0.0.71
2 years ago
0.0.72
2 years ago
0.0.52
2 years ago
0.0.53
2 years ago
0.0.54
2 years ago
0.0.55
2 years ago
0.0.56
2 years ago
0.0.50
2 years ago
0.0.49
2 years ago
0.0.48
2 years ago
0.0.47
2 years ago
0.0.46
2 years ago
0.0.45
2 years ago
0.0.44
2 years ago
0.0.43
2 years ago
0.0.42
2 years ago
0.0.41
2 years ago
0.0.40
2 years ago
0.0.39
2 years ago