An open API service indexing awesome lists of open source software.

https://github.com/marpple/rune

Web API based Front-end SDK
https://github.com/marpple/rune

Last synced: about 1 year ago
JSON representation

Web API based Front-end SDK

Awesome Lists containing this project

README

          

rune

# Rune - Web API based Front-end SDK

Rune is a fast and robust library for building high-quality frontend applications, serving as a modern web technology-based SDK.

- Object-oriented programming-based architecture
- Type-safe Generic Views & Enable
- Single-component Server-Side Rendering
- Sleek UI component development kit
- High portability and performance

# Getting Started

```shell
pnpm add rune-ts
npm install rune-ts
```

# Documentation

- [Website](https://marpple.github.io/rune/)
- [What is Rune?](https://marpple.github.io/rune/guide/what-is-rune.html)
- [Tutorial](https://marpple.github.io/rune/tutorial/view.html)

# Example

```typescript
interface Setting {
title: string;
on: boolean;
}

class SettingItemView extends View {
switchView = new SwitchView(this.data);

override template() {
return html`


${this.data.title}
${this.switchView}

`;
}
}

class SettingListView extends ListView {
ItemView = SettingItemView;
}

class SettingPage extends View {
private listView = new SettingListView(this.data);
private toggleAllView = new SwitchView({ on: this.isAllOn() });

override template() {
return html`



Setting


${this.toggleAllView}

${this.listView}


`;
}

protected override onRender() {
this.toggleAllView.addEventListener(Toggled, (e) => this.toggleAll(e.detail.on));
this.listView.addEventListener(Toggled, () => this.syncToggleAllView());
}

private toggleAll(on: boolean) {
this.listView.itemViews
.filter((itemView) => itemView.data.on !== on)
.forEach((itemView) => itemView.switchView.setOn(on));
}

private syncToggleAllView() {
this.toggleAllView.setOn(this.isAllOn());
}

private isAllOn() {
return this.data.every(({ on }) => on);
}
}
```

setting_controller