skuid.events.publish documentation clarification
In the documentation for skuid.events (https://docs.skuid.com/latest/en/skuid/api/skuid_events.html#examples), the publish example has the following syntax:
In working out a solution, the second input didn't come through. I was able to get it to work with slightly different syntax, however:
var config = { doSomething: true, direction: 'vertical'
}; skuid.events.publish('acme.page.resize',[config]);
Is there anything else to be aware of in the payload array parameter?
Here's the final working solution:
var filter = {
filterName:'Name1',
filterValue:'Value1'
};
skuid.events.publish("RemoveFilter", [filter], { scope: skuid.constants.EVENT_SCOPES.GLOBAL });
var config = { doSomething: true }; var eventDetails = { direction: 'vertical' };skuid.events.publish('acme.page.resize',[config,eventDetails]);
In working out a solution, the second input didn't come through. I was able to get it to work with slightly different syntax, however:
var config = { doSomething: true, direction: 'vertical'
}; skuid.events.publish('acme.page.resize',[config]);
Is there anything else to be aware of in the payload array parameter?
Here's the final working solution:
var filter = {
filterName:'Name1',
filterValue:'Value1'
};
skuid.events.publish("RemoveFilter", [filter], { scope: skuid.constants.EVENT_SCOPES.GLOBAL });
Tagged:
2
Categories
- 7.9K Questions
- 926 Ideas
- 220 Discussion Categories
- 178 General
- 9 Community Feedback
- 3 Community Info
- 18 Knowledge Base
Comments
When I subscribe like this: And then publish like you were doing initially, everything works as I'd expect: I get config and eventDetails coming through in the two console logs like I'd expect.
I may not have fully picked up on how this is supposed to work, but what I was seeing is that in the example provided in the documentation, two objects are passed into the data array in the publish API. The action sequence only picked up the first object as an input parameter. When I switched this to one object with two key value pairs, the action sequence picked up both.
i.e. change:
config = {
doSomething: true
};
var eventDetails = { config = {
doSomething: true, direction: 'vertical' }; skuid.events.publish('acme.page.resize',[config]);
I figured this might be a minor documentation issue, which took a couple hours to work out, so I thought I would spare others. Here's a screenshot of the different outputs:
This worked as I would expect:
The action sequence only picks up parameter1:
skuid.events.publish('EventName',[
{ Parameter1:ParameterValue1,
Parameter2,ParameterValue2,
Parameter2,ParameterValue3
},
{AnotherArgument:ArgumentValue}
]);
When you use the publish/subscribe API via JavaScript, you have more flexibility to publish multiple arguments and have subscription functions pick up on the additional arguments.