Skip to content

v1.1.2

Compare
Choose a tag to compare
@albertbori albertbori released this 06 Dec 16:42
· 4 commits to main since this release
bb6249a

Overview

This release adds a couple of quality-of-life improvements to VSM

Observing Generic Publishers

You can now observe generic publishers without having to erase them with .eraseToAnyPublisher(), where applicable.

Old:

struct LoaderModel {
    func load() -> AnyPublisher<MyViewState, Never> {
        Just(.loading)
            .merge(with: webRequestPublisher())
            .eraseToAnyPublisher()
    }
    ...
}

New:

struct LoaderModel {
    func load() -> some Publisher<MyViewState, Never> {
        Just(.loading)
            .merge(with: webRequestPublisher())
    }
    ...
}

KeyPath Support in MutatingCopyable

If you need to change a single value on a model's mutable property, you can now use a new overload on MutatingCopyable (thanks to @bdunay3) that allows you to mutate by key path. This enables some interesting possibilities for working with key paths. At a minimum, it provides a more straight-forward spelling for changing a single value on a struct's mutable property in a single line of code.

New:

struct LoadedModel {
    ...
    var isSaving: Bool = false

    func save(newValue: String) -> some Publisher<MyViewState, Never> {
        Just(.loaded(self.copy(mutatingPath: \.isSaving, value: true)))
            .merge(with: savePublisher(forValue: newValue))
    }
    ...
}

What's Changed

Full Changelog: v1.1.1...v1.1.2