Starwave Starwave - 1 year ago 176
TypeScript Question

Code fragment from java to typescript

Don't understand how to structurize this java code to work in typescript(javascript):

channel.join().receive("ok", new IMessageCallback() {
public void onMessage(Envelope envelope) {
System.out.println("JOINED with " + envelope.toString());

Code found here:

Was thinking about something like this:

var phoenix = (org as any).phoenixframework.channels;
var callback = new phoenix.IMessageCallback({
onMessage: function (arg) {

channel.join().receive("ok", callback);

It compiles successfully and no errors are thrown, but I don't get my callback when I join the channel.

Any insights appreciated!

Turns out I was doing it correctly, problem in connection lied elsewhere, thanks all who pitched in! :)

Answer Source

If you want to implement a Java interface you can use the following syntax.

var clickListener = android.view.View.OnClickListener({
    onClick: function (view) {
        // Do something on click

You can refer to the documentation article about android runtime and the data conversion techniques

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download