Tcl Source Code

Check-in [06e1f26911]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use closures rather than strings for after and [every]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ferrieux-nacl
Files: files | file ages | folders
SHA1: 06e1f26911b1b323140d2b83c278a56f2bfcd946
User & Date: ferrieux 2011-04-18 21:22:31
Context
2011-04-18
21:53
More concise serialization of coord-updates check-in: 7755a6cc4c user: ferrieux tags: ferrieux-nacl
21:22
Use closures rather than strings for after and [every] check-in: 06e1f26911 user: ferrieux tags: ferrieux-nacl
2011-04-16
16:01
Added 'natcl2tk' wrapper to run the same demo in true Tk, for speed comparisons. check-in: 8e4b3d24c5 user: ferrieux tags: ferrieux-nacl
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to nacl/init.natcl.

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    append ::JS $j
    set x [yield]
    uplevel 1 $x
}

# Async [after] using JS's setTimeout()
proc after {ms script} {
    if {[regexp \n $script]} {error "JS hates multiline :)"}
    append ::JS "setTimeout(\"tclDo([jsquote $script])\",$ms);\n"
}

# Async [every] using JS's setInterval()
proc every {ms script} {
    if {[regexp \n $script]} {error "JS hates multiline :)"}
    append ::JS "setInterval(\"tclDo([jsquote $script])\",$ms);\n"
}

# Delayed DOM-setting through the tclDo() trampoline
proc domset {element inner} {
    append ::JS "$element.innerHTML=[jsquote $inner];\n"
}








<
|




<
|






<
33
34
35
36
37
38
39

40
41
42
43
44

45
46
47
48
49
50
51

    append ::JS $j
    set x [yield]
    uplevel 1 $x
}

# Async [after] using JS's setTimeout()
proc after {ms script} {

    append ::JS "setTimeout(function(){tclDo([jsquote $script]);},$ms);\n"
}

# Async [every] using JS's setInterval()
proc every {ms script} {

    append ::JS "setInterval(function(){tclDo([jsquote $script]);},$ms);\n"
}

# Delayed DOM-setting through the tclDo() trampoline
proc domset {element inner} {
    append ::JS "$element.innerHTML=[jsquote $inner];\n"
}