@au-re/mosaik-events v4.2.0
mosaik-events
mosaik-events enables communication between the modules and mosaik through the mosaik api.
The library uses rimless to simplify two-way iframe communication. It can only be used from comunication across iframes.
Installation
npm i -S @au-re/mosaik-events
You can also use this library through a CDN
<script src="https://unpkg.com/@au-re/mosaik-events/lib/mosaik-events.min.js"></script>
Usage
In a module. A module is a custom website that is used as part of a dashboard/project.
import mosaik from "@au-re/mosaik-events";
// connect your module to mosaik
const connection = await mosaik.connect((data, event) => {}, options);
// send data to mosaik
connection.publish({ foo: 1 });
// close connection remove listeners
connection.close();
In addition to publishing data to mosaik, a tile can also update its own state.
connection.setState({ foo: 1 });
You can also connect more complex modules with their own backend in mosaik. For example a module that is deployed on a different host.
import mosaik from "@au-re/mosaik-events";
const events = {
onAuthChange: (authChangePayload) => console.log(authChangePayload),
};
// connect your module to mosaik
const connection = await mosaik.connect(events, options);
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago