Component.ts 746 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { removeElement } from '../util/dom-manip'
  2. // a force flag of `true` means rerender everything
  3. export type RenderForceFlags = true | { [entity: string]: boolean }
  4. export default abstract class Component {
  5. el: HTMLElement
  6. setElement(el: HTMLElement) {
  7. this.el = el
  8. this.bindGlobalHandlers()
  9. }
  10. removeElement() {
  11. this.unbindGlobalHandlers()
  12. removeElement(this.el)
  13. // NOTE: don't null-out this.el in case the View was destroyed within an API callback.
  14. // We don't null-out the View's other element references upon destroy,
  15. // so we shouldn't kill this.el either.
  16. }
  17. bindGlobalHandlers() {
  18. }
  19. unbindGlobalHandlers() {
  20. }
  21. abstract render(state: any, forceFlags: RenderForceFlags)
  22. }