0

I was using XCode 8.3 with swift 3.1 and I updated to Xcode 9 with swift 4, now in some classes when I use RXSwift, I have this error compiler logs:

class petViewModel {
    var lastPetID: Int = 0
    var refreshing = Variable<Bool>(false)
    var vaccines: Results<vaccines>? = nil
    let error = Variable<(Int,String)>(0,"") // Extra argument in call
    let changes = Variable<([Int], [Int], [Int])>([Int](), [Int](), [Int]())  // Extra argument in call
    var firstLoad = Variable<Bool>(false)

    // and more code bla bla bla

}

using RXSwift what is the best way to implement it? before was compiling me without any problem, any help, please?

Jack
  • 13,571
  • 6
  • 76
  • 98
user_Dennis_Mostajo
  • 2,279
  • 4
  • 28
  • 38

2 Answers2

0

You can use like this :

let change1 = Variable<[Int]>([Int]())
let change2 = Variable<[Int]>([Int]())
let change3 = Variable<[Int]>([Int]())

let changes = Observable.combineLatest(change1.asObservable(), change2.asObservable(), change3.asObservable())
Vini App
  • 7,339
  • 2
  • 26
  • 43
  • thanks for the answer @Vini App, but now is show me a compiler error: "Cannot use instance member 'change1' within property initializer; property initializers run before 'self' is available" – user_Dennis_Mostajo Oct 25 '17 at 20:29
  • https://stackoverflow.com/questions/45423321/cannot-use-instance-member-within-property-initializer – Vini App Oct 25 '17 at 20:42
0

I received a user @biboran response in GitHub, and the issue is that swift 4.0 currently doesn't support tuple transformations.

my Variable is not compiling because I declared it as a tuple and pass it as a variadic parameter. Just wrap it into a tuple:

let changes = Variable<([Int], [Int], [Int])>(
  ( // <-- this is a tuple I'm missing
    [Int](), 
    [Int](), 
    [Int]()
  ) // <-- this is a tuple I'm missing
)

as for my combineLatest, I have to wrap the argument into a collection (using a literal for example)

Observable.combineLatest([
  change1.asObservable(), 
  change2.asObservable(), 
  change3.asObservable()
])
user_Dennis_Mostajo
  • 2,279
  • 4
  • 28
  • 38