Last active
August 29, 2015 14:15
-
-
Save MadcapJake/a8b59a2ec665b809d009 to your computer and use it in GitHub Desktop.
Ceylon Express Typesafe Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Run the module `my.blog`." | |
shared void run() { | |
Application app; | |
app = Application(); | |
dynamic server = app.js.listen(3000, void () { | |
dynamic { | |
console.log( | |
"Express is listening to http://localhost:3000" | |
); | |
} | |
}); | |
} | |
shared dynamic AppInterface { | |
shared formal void listen(Integer port, Anything() callback); | |
} | |
shared class Application() { | |
"Encapsulates express logic that works when not interfaced" | |
dynamic dynRequire() { | |
dynamic { | |
dynamic required = require("express"); | |
//must call here; otherwise gets "type not callable" errors | |
dynamic calledRequired = required(); | |
return calledRequired; | |
} | |
} | |
"Should apply interface to javascript code" | |
AppInterface dynInit() { | |
dynamic { | |
return dynRequire(); | |
} | |
} | |
"Contains the actual js object." | |
shared AppInterface js = dynInit(); | |
} |
Excellent! I'll pull ceylon-js later this afternoon then and give it a go!
Don't forget to pull ceylon.language
as well, since the latest fixes were in native JS code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK there were a couple of issues with some of the core functions when dealing with a native function with additional stuff; I've just fixed that. And now I've just started a little express server with this: