swift3 - Combining multiple different observables into one observable -


i have problem adopting rxswift application. problem is: if have many input signals (variables different elements) can change user , changes want build 1 observable signal. think should use sort of combination operator example combinelatest allows 2 parameters combine.

let's @ example of inputs , outputs have.

import rxswift import rxcocoa  class modelview {      private let api: apitype      // inputs     let intype: variable<mwitemquerytype>     let infilterretailers: variable<set<mwretailer>>     let infiltercolors: variable<set<mwcolor>>     let infilterpriceranges: variable<set<mwpricerange>>      // outputs     let outquery: observable<mwitemquery>      init(initialtype: mwitemquerytype, api: apitype) {         self.api = api         self.intype = variable(initialtype)         self.infilterretailers = variable(set<mwretailer>())         self.infiltercolors = variable(set<mwcolor>())         self.infilterpriceranges = variable(set<mwpricerange>())          // todo how setup outquery signal here     } } 

so have problem setup outquery emits signals mwitemquery. mwitemquery signal must emitted when 1 of input parameters changed. mwitemquery emitted api fetch data server recent filters selected user. have lot of other input filter signals , don't know if operator can me.

combinelatest can accept more 2 parameters!

try:

observable.combinelatest(intype.asobservable(), infilterretailers.asobservable(), infiltercolors.asobservable(), infilterpriceranges.asobservable())     { type, filterretailers, filtercolors, filterpriceranges in          // data     }     .distinctuntilchanged()     .sharereplay(1) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -