WasmTest.icl 863 Bytes
Newer Older
Camil Staps's avatar
Camil Staps committed
1 2 3 4 5 6 7 8 9 10 11 12
module WasmTest

import StdEnv
import iTasks
import iTasks.UI.JavaScript

// This is a simple test program to try out things with the WebAssembly ABC interpreter.

Start w = doTasks task w
where
	task = updateInformation
		[UpdateUsing id (flip const) editor]
Bas Lijnse's avatar
Bas Lijnse committed
13
		() <<@ Title "WebAssembly test program"
Camil Staps's avatar
Camil Staps committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

editor :: Editor ()
editor = leafEditorToEditor
	{ LeafEditor
    | genUI          = withClientSideInit initUI genUI
    , onEdit         = onEdit
    , onRefresh      = onRefresh
    , valueFromState = valueFromState
    }
where
	genUI attributes datapath mode vst = (Ok (uia UITextView (valueAttr (JSONString "Check the browser console.")), ()), vst)
	onEdit datapath (_,()) st vst = (Ok (NoChange,st), vst)
	onRefresh datapath st _ vst = (Ok (NoChange,st), vst)
	valueFromState s = Just s

	initUI me world
		= jsTrace "Hello world from WebAssembly!" world