Pure icon indicating copy to clipboard operation
Pure copied to clipboard

Minimal example

Open Alex293 opened this issue 7 years ago • 2 comments

Hi,

Can you provide a minimal example ?

I don't get how to access dependencies, shouldn't Module have properties for dependencies and payload ? What the point of providing default initializers if dependencies / payload are thrown away ?

Alex293 avatar Jun 18 '18 16:06 Alex293

Hi, you can store dependency in the initializer like this if you needed to access the dependency after the initializing.

import UIKit

import Pure

final class SomeViewController: UIViewController, FactoryModule {

  // MARK: Module

  struct Dependency {
    ...
  }

  struct Payload {
    ...
  }


  // MARK: Properties

  private let dependency: Dependency


  // MARK: Initializing

  init(dependency: Dependency, payload: Payload) {
    self.dependency = dependency
    super.init()
    // Do initializing
  }

  ...

}

I hope this is what you intended. 😃

innocarpe avatar Jun 19 '18 03:06 innocarpe

Better late than never 😄 https://github.com/devxoul/Pure/pull/15 (example without Pure - Lazy Dependency) https://github.com/devxoul/Pure/pull/14 (example with Pure)

nonameplum avatar Feb 22 '20 14:02 nonameplum