# UserEvents

**URL:** <https://forums.fusetools.com/t/userevents/5180>\
**Category:** How-to Discussions\
**Created:** [January 24, 2017, 8:05pm UTC](https://forums.fusetools.com/t/userevents/5180 "2017-01-24T20:05:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ana\_Almeida](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Ana\_Almeida](https://forums.fusetools.com/u/Ana_Almeida)\
**Post date:** [January 24, 2017, 8:05pm UTC](https://forums.fusetools.com/t/userevents/5180/1 "2017-01-24T20:05:01Z")

</div>

Hi guys,

One quick question. I’m using UserEvents in my app. I used it before and it worked just fine, but at this moment it has a strange behaviour.

I have in my MainView.ux the UserEvent declared:

```auto
<UserEvent ux:Name="saveEditPlanning" />

```

And then in the page I want to Raise the event, with one argument:

```auto
<RaiseUserEvent EventName="saveEditPlanning">
	<UserEventArg Name="planningSaved" StringValue=“DATA_SAVED” />
</RaiseUserEvent>

```

And when I want to get the Event:

```auto
<OnUserEvent EventName="saveEditPlanning">
	<Callback Handler="{updateData}" />
</OnUserEvent>

```

```auto
function updateData(args){
	console.log("updateData");
	console.log(JSON.stringify(args));
	console.log(JSON.stringify(args.planningSaved));
}

```

in which the logs show:

```auto
LOG: updateData

```

```auto
LOG: {
	"node": {
		"external_object": {},
		"_raw_Parameter": {
			"_subscribers": [null, null],
			"_isLeaf": true,
			"_values": [“…”]
		},
		"_Parameter": {
			"_subscribers": [null],
			"_isLeaf": false,
			"_values": [{
				"args": {
					…
				}
			}]
		}
	},
	"data": {
		"date": {
			"_subscribers": [null],
			"_isLeaf": true,
			"_values": ["Monday, 2 January 2017"]
		},
		… ,
		"planning": {
			"_subscribers": [null],
			"_isLeaf": true,
			"_values": [{
				"args": {
					…
				}
			}]
		}
	},
	"sender": "PlanningDetails"
}

```

```auto
LOG: null

```

The problem here is that I can’t get the arguments passed when I raise the event, it shows me everything but the argument. And my argument is null.

When I navigate to the page I pass as parameter an object with the data I need to show, which is in this “args”.

Have some of you ever see something like this and know how to fix?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![kusma](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kusma/32/595_2.png) [@kusma](https://forums.fusetools.com/u/kusma)\
**Post date:** [January 25, 2017, 12:44pm UTC](https://forums.fusetools.com/t/userevents/5180/2 "2017-01-25T12:44:41Z")

</div>

I just did a quick test to see if this works or not, and it worked just fine for me. Could you perhaps try to post a minimal reproduction case?

---

<div class="post-metadata">

**Author:** ![kusma](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kusma/32/595_2.png) [@kusma](https://forums.fusetools.com/u/kusma)\
**Post date:** [January 25, 2017, 12:47pm UTC](https://forums.fusetools.com/t/userevents/5180/3 "2017-01-25T12:47:25Z")

</div>

Another curious detail is that `arg.name` also doesn’t seem to exist in your case. It should as far as I can see be equal to the `EventName`, in your case “saveEditPlanning”…

---

<div class="post-metadata">

**Author:** ![kusma](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kusma/32/595_2.png) [@kusma](https://forums.fusetools.com/u/kusma)\
**Post date:** [January 25, 2017, 12:53pm UTC](https://forums.fusetools.com/t/userevents/5180/4 "2017-01-25T12:53:30Z")

</div>

I just noticed something that seemed a bit relevant: if you wrap your function in an Observable, the args doesn’t seem to be propagated as you might expect. So if you’re doing something along those lines (as opposed to just exporting the function directly), this might be your culprit. I don’t think this is a defect though, as I’m not sure how well-defined defined operations like this is.

---

<div class="post-metadata">

**Author:** ![Ana\_Almeida](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Ana\_Almeida](https://forums.fusetools.com/u/Ana_Almeida)\
**Post date:** [February 14, 2017, 11:01am UTC](https://forums.fusetools.com/t/userevents/5180/5 "2017-02-14T11:01:02Z")

</div>

I’m still not able to use the argumentos on UserEvents, still don’t understand why. For some reason in this app I’m not able to do it, but in a older app I built some months ago works.  
It is possible that something I’m using in this new app can interfere with the arguments on a UserEvent?

Minimal reproduction case between pages:

MainView.ux

```auto
<UserEvent ux:Name=“event” />

```

Where I want to raise the event with the argument

```auto
<RaiseUserEvent EventName="event">
	<UserEventArg Name="message" StringValue="Hello from UX!" />
</RaiseUserEvent>

```

Where I want to catch the event

```auto
<OnUserEvent EventName="event">
	<Callback Handler="{eventHandler}” />
</OnUserEvent>

<JavaScript>
        function eventHandler(arg){
	       console.log(arg.message);
	       console.log(JSON.stringify(arg));
       }

       module.exports = {
	       menuStatus : menuStatus,
	       setMenuStatus : setMenuStatus,
	       activePage : activePage,
	       eventHandler : eventHandler
       }

</JavaScript>

```

`console.log(arg.message);` outputs `null`

`console.log(JSON.stringify(arg));` outputs

```auto
{
	"node": {
		"external_object": {}
	},
	"data": {
		"menuStatus": {
			"_origin": -115,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": false,
			"_values": ["noMenu"],
			"_beganSubscriptions": true
		},
		"activePage": {
			"_origin": -120,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": true,
			"_values": ["Planning"],
			"_subscriptionWatchers": [{
				"watcherId": 41
			}],
			"_beganSubscriptions": true
		}
	},
	"sender": "EdgeNavigator"
}

```

But if I create the event, raise it and handle it on the same page it seems to work.

```auto
<UserEvent ux:Name="teste" />
<OnUserEvent EventName="teste" Handler="{testeHandler}" />

<Time.PrimaryButton Text="TEST" Margin="40,30,40,0">
	<Clicked>
		<RaiseUserEvent EventName="teste">
			<UserEventArg Name="message" StringValue="Hello from UX!" />
		</RaiseUserEvent>
	</Clicked>
</Tim.PrimaryButton>

<JavaScript>
	function testeHandler(arg){
		console.log(arg.message);
		console.log(JSON.stringify(arg));
	}

	module.exports = {
		testeHandler : testeHandler
	}
</JavaScript>

```

`console.log(arg.message);` outputs `Hello from UX!`

`console.log(JSON.stringify(arg));` outputs

```auto
{
	"node": {
		"external_object": {}
	},
	"data": {
		"username": {
			"_origin": -4,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": false,
			"_values": ["..."],
			"_beganSubscriptions": true
		},
		"password": {
			"_origin": -5,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": false,
			"_values": ["..."],
			"_beganSubscriptions": true
		},
		"showToast": {
			"_origin": -6,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": false,
			"_values": [false],
			"_beganSubscriptions": true
		},
		"toastText": {
			"_origin": -7,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": false,
			"_values": [""],
			"_beganSubscriptions": true
		},
		"toastColor": {
			"_origin": -8,
			"_subscribers": [{
				"version": 2,
				"active": true
			}],
			"_isProxy": false,
			"_values": [""],
			"_beganSubscriptions": true
		}
	},
	"name": "teste",
	"message": "Hello from UX!"
}

```

Thanks in advance.
