iOS error

Back to How-to Discussions

Hi guys.

I have a problem with my application running on iOS.

I get the following error:

LOG: Error: Route parameter must be serializeable, cannot contain functions.</Users/anaalmeida/Library/Application Support/Fusetools/Packages/Fuse.Navigation/0.42.4/$.uno:2315>

In the Preview and in the Android device, it all runs with no problem.

I believe the problem is in the code:

router.push("MainPagePlanning", {}, "PlanningEdit", {planningDetails : planning.value});

where planning is a Observable:

var planning = this.Parameter.map(function(args){
                      ...
              return args.args;
        });

Why does this error only shows on iOS? Is there something that can fix it?

Thanks!

Hi!

There is no particular reason why this should only happen on iOS. It depends on what you keep inside your planning observable. It seems that on iOS, it is a function, for some reason.

Without more code/context it is hard to say what's wrong.

Hi Anders, thank you for your reply.

This is the code I have regarding the planning observable:

var Observable = require("FuseJS/Observable");
var moment = require('Modules/Moment/moment.js');
var _ = require("Modules/Lodash/lodash.js");

var date = Observable('');
var projectName = Observable('');
var breakdownName = Observable('');
var timeFrom = Observable('');
var timeTo = Observable('');
var duration = Observable('');
var status = Observable('');
var location = Observable('');
var projectManager = Observable('');
var resource = Observable('');
var otherResources = Observable();
var description = Observable('');
var remarks = Observable('');

var planning = this.Parameter.map(function(args){
	date.value = moment(args.args.data.date).format('dddd, D MMMM YYYY');
	timeFrom.value = args.args.data.timeFrom;
	timeTo.value = args.args.data.timeTo;
	duration.value = args.args.data.hours;
	projectName.value = args.args.data.projectName;
	breakdownName.value = args.args.data.breakdownName;
	status.value = args.args.data.status;
	location.value = args.args.data.location;
	resource.value = args.args.data.resourceFullName;
	otherResources.clear();
	_.forEach(args.args.data.resources, function(resource){
		otherResources.add({name : resource.name});
	});
	description.value = args.args.data.description;
	remarks.value = args.args.data.remarks;
	projectManager.value = args.args.data.projectManager;

	return args.args;
});

Do you see anything that may be causing this error on iOS?

Hi,

It is very bad practice to use .map() to write to external observables like this, it can cause all sorts of errors, and requires a separate subscription to planning. The point with .map() is to return a new value, not to cause side effects.

Consider using this.Parameter.onValueChanged(module, function(p) { ... instead.

Try doing a console.dir(args.args) and see what comes out in the console.

I've changed the code to include this.Parameter.onValueChanged(module, function(p) { ... }

this.Parameter.onValueChanged(module, function(p){
	date.value = moment(p.args.data.date).format('dddd, D MMMM YYYY');
	timeFrom.value = p.args.data.timeFrom;
	timeTo.value = p.args.data.timeTo;
	duration.value = p.args.data.hours;
	projectName.value = p.args.data.projectName;
	breakdownName.value = p.args.data.breakdownName;
	status.value = p.args.data.status;
	location.value = p.args.data.location;
	resource.value = p.args.data.resourceFullName;
	otherResources.clear();
	_.forEach(p.args.data.resources, function(resource){
		otherResources.add({name : resource.name});
	});
	description.value = p.args.data.description;
	remarks.value = p.args.data.remarks;
	projectManager.value = p.args.data.projectManager;

	planning.value = p.args;
});
````

but still get the same error, only on iOS.

Error: Route parameter must be serializeable, cannot contain functions. ```

Try to print the route parameters i.e. the values passed to router.push(..) or router.goto(..) to the console on iOS, it seems to contain a function, for some reason.

Solved it by playing around with the arguments. But still don't know why on Android and Preview it worked.

Thanks for your help.

Post Stats
  • 6
    replies
  • 581
    views
  • 2
    users