1.3.0 • Published 4 years ago

onorix v1.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Onorix

Yet another NodeCG plugin for Vue.js 3.x

Table of Contents

Installation

npm install onorix@next

Usage

Replicant

You can define replicants in setup() by calling replicant().

import { replicant } from "onorix";
import { defineComponent } from "vue";

const Component = defineComponent({
  setup() {
    const hello = replicant("hello", {
      defaultValue: "Hello World",
    });

    return {
      hello,
    };
  },
});

You can also call replicantAsync() in order to wait until the replicant is defined before mounting the component. This approach can be useful if you want to use <Suspense />.

import { replicantAsync } from "onorix";
import { defineComponent } from "vue";

const Component = defineComponent({
  async setup() {
    const hello = await replicantAsync("hello", {
      defaultValue: "Hello World",
    });

    return {
      hello,
    };
  },
});

If you want to retrieve a replicant value once, you can use readReplicant() and readReplicantAsync(). Their usage is the same as previously explained but the value will be readonly and not be updated.

Message Listener

If you want to listen to messages from NodeCG, you can use listenFor() in setup().

import { listenFor } from "onorix";
import { defineComponent, reactive } from "vue";

const Component = defineComponent({
  async setup() {
    const list = reactive([]);

    listenFor("newItem", (item) => {
      list.push(item);
    });

    return {
      list,
    };
  },
});

Author

Alexandre Breteau - @0xSeldszar

License

MIT © Alexandre Breteau

2.0.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago