Skip to content

Commit

Permalink
split UI interface into Renderer and Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdata committed Apr 10, 2024
1 parent 28f23b1 commit 160a625
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
9 changes: 9 additions & 0 deletions renderer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package jaws

import "io"

type Renderer interface {
// JawsRender is called once per Element when rendering the initial webpage.
// Do not call this yourself unless it's from within another JawsRender implementation.
JawsRender(e *Element, w io.Writer, params []any) error
}
13 changes: 2 additions & 11 deletions ui.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
package jaws

import (
"io"
)

// UI defines the required methods on JaWS UI objects.
// In addition, all UI objects must be comparable so they can be used as map keys.
type UI interface {
// JawsRender is called once per Element when rendering the initial webpage.
// Do not call this yourself unless it's from within another JawsRender implementation.
JawsRender(e *Element, w io.Writer, params []any) error

// JawsUpdate is called for an Element that has been marked dirty to update it's HTML.
// Do not call this yourself unless it's from within another JawsUpdate implementation.
JawsUpdate(e *Element)
Renderer
Updater
}
7 changes: 7 additions & 0 deletions updater.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package jaws

type Updater interface {
// JawsUpdate is called for an Element that has been marked dirty to update it's HTML.
// Do not call this yourself unless it's from within another JawsUpdate implementation.
JawsUpdate(e *Element)
}

0 comments on commit 160a625

Please sign in to comment.