Skip to content

Commit a0ce718

Browse files
committed
feat(FunctionalConfigurator): API improvements
Added `set` method to a CallableBlock type
1 parent 3cb3efa commit a0ce718

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/FunctionalConfigurator/Configurator.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ extension Configurator {
139139
_block.configurator.appendingConfiguration { _block.keyPath.embed(value, in: $0) }
140140
}
141141

142+
public func set(_ transform: @escaping (inout Value) -> Void) -> Configurator {
143+
_block.configurator.appendingConfiguration { base in
144+
_block.keyPath.embed(
145+
modification(of: _block.keyPath.extract(from: base), with: transform),
146+
in: base
147+
)
148+
}
149+
}
150+
142151
public subscript<LocalValue>(
143152
dynamicMember keyPath: WritableKeyPath<Value, LocalValue>
144153
) -> CallableBlock<LocalValue> {

0 commit comments

Comments
 (0)