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

abstract class Scope #27

Closed
Tracked by #5
DrSensor opened this issue Oct 15, 2022 · 1 comment
Closed
Tracked by #5

abstract class Scope #27

DrSensor opened this issue Oct 15, 2022 · 1 comment
Labels
data binding Everything related to data binding enhancement New feature or request

Comments

@DrSensor
Copy link
Owner

DrSensor commented Oct 15, 2022

import * as ptr from "vheap.ts"

/** @ts-rule noImplicitOverride */
abstract class Scope {
  $host = ptr.hostElement

  protected abstract on$load(state?: "init" | "revisit")

  protected abstract on$bind(state?: "unbind" | "rebind")
  unbind() {...}
  bind() {...}
  rebind() {
    ...
    this.unbind()
    this.bind()
  }

  protected abstract on$transition(next: Document | Element)

  protected abstract on$remove()
  remove() {...}
}

export default function(Base: Class) {
  ...
} as typeof Scope | (Base: Class) => typeof Scope

Note the lifecycle hook is protected which mean user should not override it outside the class declaration

The dollar sign is reserved for:

  • excluding it from binding
  • use for detecting if props/methods is runtime specific hook
  • to be override by 3rd-party library at runtime (i.e this.on$remove = customRemovalFn)

Usage

export default class extends Scope {}

or when used in mixin

export default BaseClass => class extends Scope(BaseClass) {}

💡 Tip: Check if new.target is defined. When false, return BaseClass => abstract class extends BaseClass

@DrSensor DrSensor added the enhancement New feature or request label Oct 15, 2022
@DrSensor DrSensor added this to the 1.0.0 milestone Oct 15, 2022
@DrSensor DrSensor changed the title abstract class Scope abstract class Scope Oct 15, 2022
@DrSensor DrSensor added the data binding Everything related to data binding label Oct 26, 2022
@DrSensor DrSensor mentioned this issue Nov 1, 2022
8 tasks
@DrSensor DrSensor removed this from the 1.0.0 milestone Jan 17, 2023
@DrSensor
Copy link
Owner Author

I'm really not sure about this. Both conditional and list rendering rely on slot so it actually doesn't attach or remove dom node from document. Even <render-scope>.disconnectedCallback() only being called if author use ref. No framework abstraction over it.

@DrSensor DrSensor closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data binding Everything related to data binding enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant