I decided that rather than playing with dummy code to learn I’ll redo a web app I already have, done in Vaadin. That gives me a very clear specification what to do. Vaading of course requires a JEE webcontainer since it uses servlets. With the years, I’m liking JEE less and less. It is starting to feel like an neccesarry evil that can’t be avoided. I really did not want to use a JEE webcontainer to serve REST calls, I wanted something smaller, less heavy.
Fortunately I stumbled upon something wonderful: Vertx 3! Really cool! Really simple to use! So far, just works! The many horrors I’ve experienced with the Eclipse IDE tend to make me turn around and run when I see the word “Eclipse” anywhere, but Vertx is an Eclipse project and I must say that I have the highest respect for the people behind it!
No! The vertx3-eventbus-client documentation said do:
So I tried:
Which resulted in
I did get the following to work:
Note that the new keyword is gone! Here it actually created an instance and it tried to connect! However, as soon as I replaced the hardcoded arguments with variables I got an error very similar to the first error:
Importing the EventBus was also wrong way to go since when run vertx3-eventbus-client.js did not provide what was expected.
I did start with something else, don’t remember what, that failed to include all dependencies, but when I switched to WebPack I was able to get all dependencies into my bundle.js only requiring a very simple index.html.
I at first tried the following:
This of course did not work! Probably because I’m declaring a Typescript class of something that isn’t a Typescript compatible JS code.
So this was a complete bust! So, what to do then ? When failing, pick yourself up and try again, and again util success or something like that. Well my first fail was at googling, so I tried that again, and … Success! It was actually through this were mikeagarza posted the link. The class is created by benorama (Benoit Hediard). Thanks for that!
Here is the small code I used to test:
I have verified that I can connect and send a message that does arrive using this. This is a clean implementation of the Vertx event bus client done entirely in Typescript. It does not take any args in the constructor, but have a
connect(...) method instead to make it Angular2 injectable. Very nice.
The following server code sets up the bridge (Groovy code!):