Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting event listener to asyncReplace #343

Open
nmattia opened this issue Jan 8, 2024 · 0 comments
Open

Allow setting event listener to asyncReplace #343

nmattia opened this issue Jan 8, 2024 · 0 comments

Comments

@nmattia
Copy link

nmattia commented Jan 8, 2024

It would be nice if lit-analyzer allowed settings event listeners to (well-typed) asyncReplace instances. Here's a simple (though somewhat silly) example where the click function changes depending on the date (there's definitely better ways to do this but lit seems to accept this):

import {html, LitElement} from 'lit';
import {customElement} from 'lit/decorators.js';
import {asyncReplace} from 'lit/directives/async-replace.js';

async function *getUrl() {
  while (true) {
    const date = new Date();
    const day = date.getDay();
    yield "https://example.com/days/" + day;
    await new Promise(resolve => setTimeout(resolve, 1000));
  }
}

@customElement('button-date')
export class ButtonDate extends LitElement {
  render() {
    return html`<button 
         @click=${asyncReplace(getUrl(), url => fetch(url as any))}>
          submit today</button>`;
  }
}
nmattia added a commit to dfinity/internet-identity that referenced this issue Jan 8, 2024
This adds a lit-analyzer lint check. This ensures we make correct use of
lit templates.

We disable three rules which currently appear to be overrestrictive:
* runem/lit-analyzer#341
* runem/lit-analyzer#342
* runem/lit-analyzer#343
nmattia added a commit to dfinity/internet-identity that referenced this issue Jan 8, 2024
This adds a lit-analyzer lint check. This ensures we make correct use of
lit templates.

We disable three rules which currently appear to be overrestrictive:
* runem/lit-analyzer#341
* runem/lit-analyzer#342
* runem/lit-analyzer#343
github-merge-queue bot pushed a commit to dfinity/internet-identity that referenced this issue Jan 8, 2024
This adds a lit-analyzer lint check. This ensures we make correct use of
lit templates.

We disable three rules which currently appear to be overrestrictive:
* runem/lit-analyzer#341
* runem/lit-analyzer#342
* runem/lit-analyzer#343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant