0.0.115 • Published 3 months ago

stitch-sdk v0.0.115

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

stitch-sdk

Usage

yarn:

yarn add stitch-sdk

npm:

npm install stitch-sdk

Integrate Stitch's app/module into existing app page

  1. Publish your app/module in Stitch.
  2. Set the app/module's access privilege as public.
  3. 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

NameTypeDescriptionDefault value
appIdstringThe app's id in Stitch. Required!--
baseUrlstringStitch's api base urlhttps://api.openblocks.dev
onModuleEventTriggered(eventName: string) => voidTriggered when module's custom event is triggered. Works only when the app is a module.--
onModuleOutputChange(output: any) => voidTriggered 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

3 months ago

0.0.114

3 months ago

0.0.113

3 months ago

0.0.112

3 months ago

0.0.111

3 months ago

0.0.110

3 months ago

0.0.96

3 months ago

0.0.97

3 months ago

0.0.98

3 months ago

0.0.99

3 months ago

0.0.101

3 months ago

0.0.100

3 months ago

0.0.95

3 months ago

0.0.90

3 months ago

0.0.91

3 months ago

0.0.92

3 months ago

0.0.93

3 months ago

0.0.94

3 months ago

0.0.89

3 months ago

0.0.84

3 months ago

0.0.85

3 months ago

0.0.86

3 months ago

0.0.87

3 months ago

0.0.88

3 months ago

0.0.80

3 months ago

0.0.81

3 months ago

0.0.82

3 months ago

0.0.83

3 months ago

0.0.77

3 months ago

0.0.78

3 months ago

0.0.79

3 months ago

0.0.62

6 months ago

0.0.63

6 months ago

0.0.64

6 months ago

0.0.65

6 months ago

0.0.66

6 months ago

0.0.67

6 months ago

0.0.68

6 months ago

0.0.60

7 months ago

0.0.61

6 months ago

0.0.59

7 months ago

0.0.73

6 months ago

0.0.74

6 months ago

0.0.75

6 months ago

0.0.76

6 months ago

0.0.57

7 months ago

0.0.58

7 months ago

0.0.70

6 months ago

0.0.71

6 months ago

0.0.72

6 months ago

0.0.52

7 months ago

0.0.53

7 months ago

0.0.54

7 months ago

0.0.55

7 months ago

0.0.56

7 months ago

0.0.50

8 months ago

0.0.49

8 months ago

0.0.48

8 months ago

0.0.47

8 months ago

0.0.46

8 months ago

0.0.45

8 months ago

0.0.44

8 months ago

0.0.43

8 months ago

0.0.42

8 months ago

0.0.41

8 months ago

0.0.40

8 months ago

0.0.39

8 months ago