Add .let cases to set immutable key values
RoyalIcing opened this issue · 0 comments
RoyalIcing commented
- Skips on rerenders, to make rerendering fasters
Choice 1
enum ButtonProp {
case let(…)
case set(…)
}
func button(_ key: String, _ props: [ButtonProp<Msg>]) -> ViewElement<Msg>
Choice 2
func button(_ key: String, let: [ButtonProp<Msg>] = [], _ var: [ButtonProp<Msg>]) -> ViewElement<Msg>
Choice 3
func button(_ key: String, _ props: [ButtonProp<Msg>], letProps: ButtonProp<Msg>…) -> ViewElement<Msg>
Choice 4
struct ViewElementTemplate<Prop> {
var key: String
var props: [Prop]
private var makeElement: (String, [Prop]) -> ViewElement
init(_ key: String, `let` letProps: [Prop]) {
self.key = key
self.props = letProps
}
func vary(_ varProps: Prop) {
var props = self.props
props.append(varProps)
return makeElement(key, props)
}
}
func button(_ key: String, `let` letProps) -> ButtonTemplate<Msg>