SwitchEventStream breaks parent Signal's lazy-initial-value contract
See original GitHub issueI found a very strange behavior in my system. For now I have not created a small repro but issue seems very serious so I give you a recap of my trying to narrow down the problem.
val openSessionRequest = new EventBus[ImportSourceEntry]
val importFileProcessApiClient1 =
appCanvas.$clients.value.map(_.map(_.importFileProcessApiClient))
val importFileProcessApiClient2 =
appCanvas.$clients.value.map(_.map(_.importFileProcessApiClient))
val testResult = Val("test1")
.combineWith(importFileProcessApiClient2)
.flatMap { t =>
EventStream.fromValue("test")
}
… later in code I put some monitoring of what’s going on
div(
importFileProcessApiClient --> { client =>
error(s"client monitoring mapped val 1 ${client}")
},
importFileProcessApiClient2 --> { client =>
error(s"client monitoring mapped val 2 ${client}")
},
appCanvas.$clients is an SignalOptionT from laminext so a thin wrapper around Signal[Option[T]] and it’s value starts with None and then later changes to Some(…)
so importFileProcessApiClient1 and importFileProcessApiClient2 are identical, the only difference is that importFileProcessApiClient2 is used in constructing testResult
what I got is ‘client monitoring mapped val 1 Some(feecompass.app.panel.web.app.AppCanvas$$anon$18@37)’ ‘client monitoring mapped val 2 None’
if I remove the usage of importFileProcessApiClient2 i got what’s expected 'client monitoring direct mapped 1 Some(feecompass.app.panel.web.app.AppCanvas$$anon$18@37) ’ 'client monitoring direct mapped 2 Some(feecompass.app.panel.web.app.AppCanvas$$anon$18@37) ’
if I switch the usage of 1 and 2 the problem appears on 1 'client monitoring mapped val 1 None ’ ‘client monitoring mapped val 2 Some(feecompass.app.panel.web.app.AppCanvas$$anon$18@35)’
Now the strange part testResult is not used anywhere. The trigger for the problem is
.flatMap({ case (_, _) =>
EventStream.fromValue("test")
})
if I comment it out then it works as expected.
If testResult is used for instance in div(child <-- testResult.map(t => div(t.toString)), ...
the wrong behavior stays the same.
On the other hand switching to FlattenStrategy.ConcurrentStreamStrategy
resolves the problem.
It looks as if adding that flatMap with FlattenStrategy.SwitchStreamStrategy messes things up somehow and it’s not related to actual usage of the resulting Observable but just the fact of constructing it. I will let you know if I find something more.
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (13 by maintainers)
Top GitHub Comments
copy paste before I changed to 1 & 2 but to see the diference clearly.
@pbuszka I’ve just released Airstream branch
rough-flatten-fix
as0.13.2-RC1
. It will be up on Maven Central shortly.