File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
instantsearch/src/commonMain/kotlin/com/algolia/instantsearch/filter/facet/dynamic/internal Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.algolia.instantsearch.filter.facet.dynamic.internal
2
2
3
3
import com.algolia.instantsearch.core.Callback
4
4
import com.algolia.instantsearch.core.connection.AbstractConnection
5
+ import com.algolia.instantsearch.filter.facet.dynamic.AttributedFacets
5
6
import com.algolia.instantsearch.filter.facet.dynamic.DynamicFacetListViewModel
6
7
import com.algolia.instantsearch.filter.facet.dynamic.SelectionsPerAttribute
7
8
import com.algolia.instantsearch.filter.state.FilterGroupDescriptor
@@ -30,6 +31,13 @@ internal class DynamicFacetListConnectionFilterState(
30
31
) : AbstractConnection() {
31
32
32
33
private val filterStateSubscription: Callback <Filters > = {
34
+ updateSelections()
35
+ }
36
+
37
+ private val facetOrderSubscription: Callback <List <AttributedFacets >> = {
38
+ updateSelections()
39
+ }
40
+ private fun updateSelections () {
33
41
val selectionsPerAttribute = viewModel.orderedFacets
34
42
.asSequence()
35
43
.map { it.attribute }
@@ -67,12 +75,14 @@ internal class DynamicFacetListConnectionFilterState(
67
75
68
76
override fun connect () {
69
77
super .connect()
78
+ viewModel.onFacetOrderChanged.subscribe(facetOrderSubscription)
70
79
viewModel.onSelectionsComputed.subscribePast(onSelectionsComputedSubscription)
71
80
filterState.filters.subscribePast(filterStateSubscription)
72
81
}
73
82
74
83
override fun disconnect () {
75
84
super .disconnect()
85
+ viewModel.onFacetOrderChanged.unsubscribe(facetOrderSubscription)
76
86
viewModel.onSelectionsComputed.unsubscribe(onSelectionsComputedSubscription)
77
87
filterState.filters.unsubscribe(filterStateSubscription)
78
88
}
You can’t perform that action at this time.
0 commit comments