levibostian / iOSBlanky

My opinionated iOS app boilerplate
MIT License
6 stars 5 forks source link

Sourcery make AutoLense more convenient. #38

Closed levibostian closed 4 years ago

levibostian commented 4 years ago

Right now, Sourcery's default AutoLense template is good, but it could be more convenient.

Before:

protocol Foo: AutoLense {
  let id: String
}

var foo = Foo(id: "123")
foo = Foo.idLense.set("new-id", foo)

After:

protocol Foo: AutoLense {
  let id: String
}

var foo = Foo(id: "123")
foo = Foo.idLense.set("new-id", foo)

...all of the previous stuff, plus...
let foo = Foo(id: "123).idLense.set("new-id")

A convenient way to be a builder for a new instance where it passes in self for me.