@holochain-open-dev/calendar-events
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

CalendarEventsModule

Small module to create and see calendar events, in holochain RSM.

This module is designed to be included in other DNAs, assuming as little as possible from those. It is packaged as a holochain zome, and an npm package that offers native Web Components that can be used across browsers and frameworks.

Please note, this module is in its early infancy, right now more usable as a reference for building reusable modules. Help is appreciated and much needed!

Documentation

See our storybook.

Assumptions

These are the things you need to know to decide if you can use this module in your happ:

  • Zome:
  • UI module:
    • ApolloClient as the state-management and data-fetching engine.
    • The resolvers are declared in the frontend using makeExecutableSchema.
    • No framework or library assumed.

Installation and usage

Including the zome in your DNA

You need to include this repository as a git submodule inside the zomes/ folder of your application.

From the root folder of your DNA:

  1. git submodule add https://github.com/holochain-open-dev/calendar-events-module zomes/calendar_events.
  2. Modify the Cargo.toml and add zomes/calendar_events in the [members] array.
  3. Add the calendar_events zome in the dna.json of your <DNA_NAME>.dna.workdir.
  4. Compile the DNA with the usual CARGO_TARGET=target cargo build --release --target wasm32-unknown-unknown .

Now the submodule is added and linked with the code from this repository. In the future, whenever this repository is cloned, run git submodule init and git submodule update.

You can read more documentation on git submodules here.

Using the UI module

  1. Install the module with npm install @holochain-open-dev/calendar-events.
  2. Add the GraphQl schema and resolvers to your ApolloClient setup:
import { AppWebsocket } from "@holochain/conductor-api";
import {
  calendarEventsTypeDefs,
  calendarEventsResolvers,
} from "@holochain-open-dev/calendar-events";

export async function setupClient(url) {
  const appWebsocket = await AppWebsocket.connect(String(url));

  const appInfo = await appWebsocket.appInfo({ app_id: "test-app" });

  const cellId = appInfo.cell_data[0][0];

  const executableSchema = makeExecutableSchema({
    typeDefs: [rootTypeDef, calendarEventsTypeDefs],
    resolvers: [calendarEventsResolvers(appWebsocket, cellId)],
  });

  const schemaLink = new SchemaLink({ schema: executableSchema });

  return new ApolloClient({
    typeDefs: allTypeDefs,
    cache: new InMemoryCache(),
    link: schemaLink,
  });
}
  1. In the root file of your application, install the module:
import { CalendarEventsModule } from "@holochain-open-dev/calendar-events";
async function initApp() {
  const client = await setupClient(`ws://localhost:8888`);

  const calendarEventsModule = new CalendarEventsModule(client);

  await calendarEventsModule.install();
}
  1. Once you have installed the module, all the elements you see in our storybook will become available for you to use in your HTML, like this:
...
<body>
  <hod-my-calendar></hod-my-calendar>
</body>

Take into account that at this point the elements already expect a holochain conductor running at ws://localhost:8888.

Developer setup

This respository is structured in the following way:

  • Top level src/ and Cargo.toml contains the code for the zome itself. This is to allow direct usage of the zome through git submodule.
  • ui/: UI library.
  • example-dna/: an example of a DNA that uses the zome. It contains a link to the zome code and its tryorama tests.

Read the UI developer setup and the Zome developer setup.

Readme

Keywords

none

Package Sidebar

Install

npm i @holochain-open-dev/calendar-events

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

2.32 MB

Total Files

15

Last publish

Collaborators

  • matthme
  • zippy314
  • guillem.cordoba