File tree Expand file tree Collapse file tree 2 files changed +33
-12
lines changed Expand file tree Collapse file tree 2 files changed +33
-12
lines changed Original file line number Diff line number Diff line change 1
- {- This requires a port subscription by the host application.
1
+ port module Lib.ProdDebug exposing (..)
2
2
3
- Something like:
3
+ import Html exposing (Html , node )
4
+ import Html.Attributes exposing (attribute )
4
5
5
- ```javascript
6
- const app = Elm.HostApp.init({ flags });
7
6
8
- if (app.ports) {
9
- app.ports.debugLog?.subscribe((text) => {
10
- console.debug(text);
11
- });
12
- }
13
- ```
14
- -}
7
+ view : String -> List (Html msg ) -> Html msg
8
+ view debugMessage content =
9
+ node " prod-debug" [ attribute " message" debugMessage ] content
15
10
16
11
17
- port module Lib.ProdDebug exposing (..)
12
+ {- | This requires a port subscription by the host application.
18
13
14
+ Something like:
19
15
16
+ ```javascript
17
+ const app = Elm.HostApp.init({ flags });
18
+
19
+ if (app.ports) {
20
+ app.ports.debugLog?.subscribe((text) => {
21
+ console.debug(text);
22
+ });
23
+ }
24
+ ```
25
+
26
+ -}
20
27
port debugLog : String -> Cmd msg
Original file line number Diff line number Diff line change
1
+ // <prod-debug message="debug message"></prod-debug>
2
+
3
+ class ProdDebug extends HTMLElement {
4
+ constructor ( ) {
5
+ super ( ) ;
6
+ }
7
+
8
+ async connectedCallback ( ) {
9
+ const message = this . getAttribute ( "message" ) ;
10
+ console . debug ( message ) ;
11
+ }
12
+ }
13
+
14
+ customElements . define ( "prod-debug" , ProdDebug ) ;
You can’t perform that action at this time.
0 commit comments