title: Using swift 4 Decodable protocol with RxSwift
body: <p>I was recently trying to parse JSON to a model using Decodable protocol, and I have done that successfully. But now I want to implement bi-directional binding using RxSwift. For that I need to declare variables of type 'Variable&lt;>'.Here is a snippet from my model:</p>
  
  <pre><code>struct Person : Decodable
  {
      var batchcomplete = String()
      var `continue` = Continue()
      var query = Query()
      var limits = Limit()
  
      enum CodingKeys: String,CodingKey
      {
          case batchcomplete
          case `continue`
          case limits
          case query
      }
  
      init(from decoder: Decoder) throws
      {
          let container = try decoder.container(keyedBy: CodingKeys.self)
  
          batchcomplete = try container.decode(String.self, forKey: .batchcomplete)
          `continue` = try container.decode(Continue.self, forKey: .`continue`)
          limits = try container.decode(Limit.self, forKey: .limits)
          query = try container.decode(Query.self, forKey: .query)
      }
  }
  </code></pre>
  
  <p>Now if I change my 'batchcomplete' from String() to Variable,the init() method throws an error:</p>
  
  <pre><code>No 'decode' candidates produce the expected contextual result type 'Variable&lt;String&gt;'.
  </code></pre>
  
  <p>Make these changes and you will get the error.</p>
  
  <pre><code>var batchcomplete = Variable&lt;String&gt;("")
  batchcomplete = try container.decode(Variable&lt;String&gt;.self, forKey: .batchcomplete)
  </code></pre>