0.3.10 • Published 3 months ago

lit-q v0.3.10

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

Lit-q API Docs

A simple query and mutation library for lit-element

Installation

$ npm i lit-q
# or
$ yarn add lit-q
# or
$ pnpm add lit-q

Usage

import { html, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
import { query } from "lit-q";

@customElement("my-element")
export class MyElement extends LitElement {
  myQuery = new Query(this, "my-query", () => fetch("https://example.com"));
  myMutation = new Mutation(this, "my-mutation", () =>
    fetch("https://example.com", { method: "POST" })
  );

  render() {
    return html`
    <h1>My Query</h1>
    <p>
      ${this.myQuery.isLoading
        ? "Loading..."
        : this.myQuery.isError
        ? "Error!"
        : JSON.stringify(this.myQuery.data)}
    </p>
    <h1>My Mutation</h1>
    <button @click=${this.myMutation.mutate}>Mutate</button>
    <p>
      ${this.myMutation.isLoading
        ? "Loading..."
        : this.myMutation.isError
        ? "Error!"
        : JSON.stringify(this.myMutation.data)}
    </p>
    `;
}
0.3.10

3 months ago

0.3.9

3 months ago

0.3.8

5 months ago

0.3.6

10 months ago

0.3.7

9 months ago

0.3.5

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago