# Push from Uno to Javascript

**URL:** <https://forums.fusetools.com/t/push-from-uno-to-javascript/2331>\
**Category:** How-to Discussions\
**Created:** [October 15, 2015, 6:10am UTC](https://forums.fusetools.com/t/push-from-uno-to-javascript/2331 "2015-10-15T06:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eddie](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@Eddie](https://forums.fusetools.com/u/Eddie)\
**Post date:** [October 15, 2015, 6:10am UTC](https://forums.fusetools.com/t/push-from-uno-to-javascript/2331/1 "2015-10-15T06:10:18Z")

</div>

Hi!

Is there a way to push/call a method in javascript from Uno? So for example if Uno had a listener that was listening for messages, and when something arrives the listener in Uno will let javascript know that something has arrived.

Thanks!

Eddie

---

<div class="post-metadata">

**Author:** ![Kristian\_Hasselknipp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kristian_hasselknipp/32/549_2.png) [@Kristian\_Hasselknipp](https://forums.fusetools.com/u/Kristian_Hasselknipp)\
**Post date:** [October 15, 2015, 6:31am UTC](https://forums.fusetools.com/t/push-from-uno-to-javascript/2331/2 "2015-10-15T06:31:59Z")

</div>

Hi!

Here is how you can implement an event in Uno which calls back to your JavaScript (the docs will be updated to include this soon):

```auto
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;

namespace JSUno
{
    public class Chat : NativeModule
    {
        NativeEvent _nativeEvent;

        public Chat()
        {
            AddMember(new NativeFunction("send", (NativeCallback)SendMessage));
            _nativeEvent = new NativeEvent("onMessageReceived");
            AddMember(_nativeEvent);
        }

        object[] SendMessage(Fuse.Scripting.Context context, object[] args)
        {
            var arg = args[0] as string;
            if(arg != null)
                _nativeEvent.RaiseAsync(arg);
            else
                _nativeEvent.RaiseAsync("----");

            return null;
        }
    }
}

```

```auto
var chat = require("chat")
function send() {
    chat.send(new Date().toString());
}

chat.onMessageReceived = function(message) {
    console.log("onMessageReceived " + message);
};

```

Add this to your UX to make the chat module available in JS: `<JSUno.Chat ux:Global="chat" />`

---

<div class="post-metadata">

**Author:** ![Eddie](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@Eddie](https://forums.fusetools.com/u/Eddie)\
**Post date:** [October 16, 2015, 1:50pm UTC](https://forums.fusetools.com/t/push-from-uno-to-javascript/2331/3 "2015-10-16T13:50:43Z")

</div>

thanks! that worked like a charm 🙂
