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

questionnaireStateFlow not emitting as expected #1427

Closed
joiskash opened this issue May 27, 2022 · 1 comment · Fixed by #1486
Closed

questionnaireStateFlow not emitting as expected #1427

joiskash opened this issue May 27, 2022 · 1 comment · Fixed by #1486
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working

Comments

@joiskash
Copy link
Collaborator

Describe the bug
The questionnaireStateFlow is a combination of two flows

  1. Modification count
  2. pageFlow

The expectation is that every time modificationCount changes i.e. every time an answer changes due to user action, the combination of the flow should trigger resulting in getQuestionnaireState emitting a new state that is continuously being collected by the QuestionnaireFragment.

We have noticed that the state is collected only when pageFlow changes and not when modification count changes.

Component
SDC library

To Reproduce
Steps to reproduce the behavior:

  1. Open a questionnaire in debugging mode
  2. Add a break point where adpater.submitList(list) is called.
  3. Make a change in the any answer
  4. The break point will not get triggered
  5. Add a break point in getQuestionnaireState
  6. Make a change in any answer
  7. The Break point will trigger

Expected behavior
Combination of two flows should result in an emit operation when either of the flows change.

This issue is linked #227

@Tarun-Bhardwaj Tarun-Bhardwaj added the type:bug Something isn't working label Jun 30, 2022
@joiskash
Copy link
Collaborator Author

joiskash commented Jul 4, 2022

According to Strong equality-based conflation section in https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/

Values in state flow are conflated using Any.equals comparison in a similar way to distinctUntilChanged operator. It is used to conflate incoming updates to value in MutableStateFlow and to suppress emission of the values to collectors when new value is equal to the previously emitted one. State flow behavior with classes that violate the contract for Any.equals is unspecified.

Since QuestionnaireItemViewItem is just a wrapper around the questionnaireResponse items, the new state is always equal to the old one , even after an answer is changed. Unless there is a new enabled question or page change, the questionnairestateFlow will not emit.

cc: @jingtang10 @aurangzaibumer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants