external screen
Isn’t “external screen example()” possible or is it wrong syntax? I got “Syntax error near unexpected token ‘)’”
Submitted by Terje Pedersen on 18 March 2011 at 12:06
Issue Log
Gosh, clearly nobody used this before. For some reason the syntax was:
external screen example : void ()
I’ll fix this in 0.4.2.
When using external screen example : void () instead I got “Uncaught TypeError: Cannot call method ‘get’ of undefined” from mobl.js:676 most likely the fix for 0.4.2 will fix it aswell.
Yes, you really cannot use it right now. Internally it was also broken.
external screen example()
I now get “Syntax error, not expected here: ‘screen’” and “Syntax error, expected: ‘middleware’”
Trying to add return type “: void” get rid of the errors but calling example() nothing happens.
You should indeed add
: void
there. When you call it, well, it calls the Javascript functionyour.module.example(.., ...)
(which should mimic the behavior of a generated screen).What are you trying to do exactly?
I have two modules one of them loaded. I’ve got external control working but external screen gives me currently “Cannot call method ‘get’ of undefined”
Can you show (or send me) some code that reproduces this? You can use < verbatim> (no space after <) for code in this bug tracker.
uni.mobl
module unidynamic import uni1
dynamic import uni2external control hello()
external screen example() : voidsome logic for switching between them but using only this below gives the same error
mobl.load(‘uni1.js’);
uni.impl = uni1;
mobl.implementInterface(uni.impl, uni, [‘hello’,‘example’]);uni1.mobl
module uni1
import mobl::ui::genericcontrol hello() {
label(“hello from 1”)
}screen example() {
header(“1111”)
}uni2.mobl
module uni2
import mobl::ui::genericcontrol hello() {
label(“hello from 2”)
}screen example() {
header(“2222”)
}In my main module
screen root() {
hello()
button(“call example()”, onclick={example();})
}
Alright, there was still a bug there. I forgot that in a recent update every screen got two optional arguments, implicitly added (
replace
andanimate
) and that is not handled well in this case. I’ll fix this in 0.4.3. Here’s how you can get it to work now:
application uniimport mobl::ui::generic
dynamic import uni1
dynamic import uni2external control hello()
external screen example(replace : Bool = false, animate : String = “slide”) : void// in 0.4.3 you’ll be able to write:
// external screen example() : void
mobl.load(‘uni1.js’);
mobl.implementInterface(uni1, __ns, [‘hello’,‘example’]);screen root() {
hello()
button(“call example()”, onclick={example();})
}What I changed in addition is the the
mobl.implementInterface
line, this basically hooks the definitionsuni1.hello
anduni1.example
into__ns.hello
and__ns.example
respectively.Again, it’s a bit of a hack now (with the replace and animate arguments), but you can get rid of those in the next release.
Worked :) Good to know its going to be improved in 0.4.3
Log in to post comments