Code Monkey home page Code Monkey logo

partial's People

Contributors

actions-user avatar dependabot-preview[bot] avatar dependabot[bot] avatar josephduffy avatar randomeizer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

partial's Issues

Test files are large

Each of the test files are large, causing them to be hard to read, refactor, and sometimes slow down Xcode.

Some sort of code generation tool could be used to improve the creation/updating of these files. I have tried Sourcery, but it does not seem to help the issues (it seems to mainly work on types, rather than generate files with large amounts of repetition with minor differences).

Using functions to test specific cases (such as all cases for when a value is not set) is feasible, but can make tracking down failing tests more cumbersome.

Remove use of Quick/Nimble

Quick/Nimble add overhead to testing (both as a developer checking out and overhead when running).

I personally don't use them on other projects and would like to remove them from this.

Auto-wiring sub-property PartialBuilders

Is your feature request related to a problem? Please describe.

Yet to actually use the library, but reading through the documentation for PartialBuilder in the "Building complex types" section it occurred to me that it should be possible to improve this:

struct Root {
    let size1: CGSize
    let size2: CGSize
}

let rootBuilder = PartialBuilder<Root>()
let size1Builder = PartialBuilder<CGSize>()
let size2Builder = PartialBuilder<CGSize>()

let size1Subscription = size1Builder.subscribeToAllChanges { _, size1Builder in
    try? rootBuilder.setValue(size1Builder, for: \.size1)
}
let size2Subscription = size2Builder.subscribeToAllChanges { _, size2Builder in
    try? rootBuilder.setValue(size2Builder, for: \.size2)
}

Describe the solution you'd like

It should be possible to build some infrastructure to be able to write something like this instead:

struct Root {
    let size1: CGSize
    let size2: CGSize
}

let rootBuilder = PartialBuilder<Root>()
let size1Builder = rootBuilder.builder(for: \.size1)
let size2Builder = rootBuilder.builder(for: \.size2)

Internally, the builder(for:) method would wire up the subscription for you.

Potential downside is that you can't 'unsubscribe' from changes, but I'm not sure how often that would be an issue? I'm guessing that most Partial* values just get disposed once the real value is built anyway.

A couple of options for this:

  1. Have a SubPartialBuilder (terrible class name, sorry) with an extra method for unsubscribing/etc if that's an issue? Eg:
// assuming that `builder(for:)` returns a `SubPartialBuilder`...
size2Builder.cancelSubscription() // or `.detach()` ?

Alternately to avoid needing SubPartialBuilder, this method could get added to the PartialBuilder interface and simply does nothing for top-level builders. Not sure if I like that.

  1. PartialBuilder keeps track of the subscriptions it creates via builder(for:) internally, and provides a method to unwatch a given keypath. Eg:
rootBuilder:cancelSubscriptions(for: \.size2)

The upside is, you don't need any additional classes or protocols. The downside is, you can't cancel the specific sub-PartialBuilder.

On balance, I prefer option 1. And thinking about it, I'd lean towards adding detach() to PartialBuilder, rather than adding a SubPartialBuilder subclass. But I could see arguments for both sides.

Describe alternatives you've considered

The original suggestion works, just requires more work from developers, increasing the possiblity of missing steps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.