Skip to content

Instantly share code, notes, and snippets.

@tjmonsi
Created December 15, 2021 10:44
Show Gist options
  • Select an option

  • Save tjmonsi/218358b2f5f5d2132a14b45237fb39b0 to your computer and use it in GitHub Desktop.

Select an option

Save tjmonsi/218358b2f5f5d2132a14b45237fb39b0 to your computer and use it in GitHub Desktop.
import { LitElement, html } from 'lit';
import { proxy } from 'comlink';
import { state } from '../../worker/index.js';
export class Component extends LitElement {
// ... constructor
async connectedCallback () {
super.connectedCallback();
state.subscribe('username', 'setLoggedIn', proxy(this._boundSetLoggedIn));
}
disconnectedCallback () {
if (super.disconnectedCallback) super.disconnectedCallback();
state.unsubscribe('username', 'setLoggedIn');
}
// ... setLoggedIn
}
window.customElements.define('web-header', Component);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment