Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APLComponent.When has wrong type #73

Closed
lultimouomo opened this issue Jan 5, 2020 · 2 comments
Closed

APLComponent.When has wrong type #73

lultimouomo opened this issue Jan 5, 2020 · 2 comments

Comments

@lultimouomo
Copy link

APLComponent.When was changed by PR #50 to be a boolean type, but this is not what APL expects. It is a string type that will be evaluated on the device, not on the skill backend.
This is clearly documented here:
https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/understand-apl.html#conditional-logic-and-responsive-documents

Using a boolean prevents the device-side evaluation.

@stoiveyp
Copy link
Owner

stoiveyp commented Jan 5, 2020

@lultimouomo I appreciate you raising the issue. Let me try and clarify.

when is a boolean property, one that determines if the component is to be used in the layout. It can, as with almost all APL properties, use data binding or expressions.

As we have strong typing in .NET, I handle this by making the properties APLValue<T> which gives us the underlying type we're aiming for, but means we can assign an expression as well, using the To method. So in this case

component.When = APLValue<bool?>.To("expression here")

This allows us to disable a component just using false, or as you've seen, use a string.

Hope this clears things up a bit, I'll try and add an example to the readme when I get to my laptop - I won't close the issue until then (on my phone right now) 👍

@stoiveyp
Copy link
Owner

stoiveyp commented Jan 6, 2020

@lultimouomo I've now updated the readme to mention how expressions and data binding work - I've used the example from the link you sent as that's going to be a really common scenario.

@stoiveyp stoiveyp closed this as completed Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants