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
ORKNavigationRule accepting a closure as an alternative to ORKResultPredicate #531
Comments
This is a good idea, I may look into it at a later date. |
Hey @YuanZhu-apple, I have been looking into this by drafting an API along the lines:
Where Do you think it's worth implementing anyway? I suspect having a rule class that's not archivable is not a good idea, as this would cause issues when archiving |
@rsanchezsaez The API design is OK with me.
I just realized NavigationRule is expected to be archived with ORKNavigableTask, this may not work. But I found Is it possible for |
On one hand, However, deceivingly, those
So I guess we can just leave it like that, and if somebody (@md0u80c9?) needs to use them, they must be aware that they will lose If everybody agrees, this issue can be closed. |
@rsanchezsaez Thanks for trying it! So the fact is that ORKNavigationRule can accept a closure now, but cannot be serialized(Nothing we can do about it). @md0u80c9 Can this issue be closed? |
I think this issue can be closed. |
Agree I think it can be closed. |
The proposal would be to extend ORKPredicateStepNavigationRule to take a closure as an alternative to ORKResultPredicate.
Example case: your study may contain multiple surveys/forms. Or you may have data from other areas (HealthKit being the obvious example).
Your application could then have significantly better logic from external variables, without having to resort to subclassing.
In my application example, we have some data stored in Core Data (demographics) - if the data is already present (because they have entered data from an earlier survey) we won't want to ask it in any subsequent survey. If it's not present we will ask it and then as part of our result parser put the data into Core Data.
If your application picked up an anomaly on HealthKit that might lead to a change in your survey questions (eg. diabetic has an abnormal blood sugar result from HealthKit you may want to ask extra dietary intake questions).
The closure would either return a boolean state: true ( go to the specified destination), or false. It could alternatively conceivably return a String state (destinationStepIdentifier), allowing effectively a switch-type predicate.
The text was updated successfully, but these errors were encountered: