Coder Social home page Coder Social logo

plivesey / consistencymanager Goto Github PK

View Code? Open in Web Editor NEW
372.0 372.0 33.0 1.5 MB

A library that manages consistency of immutable models

Home Page: https://plivesey.github.io/ConsistencyManager-iOS/

License: Apache License 2.0

Ruby 0.38% Swift 99.33% Shell 0.29%

consistencymanager's People

Contributors

albinekcom avatar asowers1 avatar dustin-shean-linkedin avatar hebertialmeida avatar jdhealy avatar li-kramgopa avatar plivesey avatar rishabhtayal avatar sachinvas-halodoc avatar satanwoo avatar vargon 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

consistencymanager's Issues

Rename project to ConsistencyManager

-iOS is wrong now since it handles tvOS and macOS. The pod is also called ConsistencyManager. This shouldn't be a problem because there are no other big projects with this name.

Carthage support

ConsitencyManager is best paired with 🚀 Data (which does support Carthage), but it would be great if folks could consume the framework directly via Carthage.

collections

can u please give an example for use with collections?
I have a view controller that holds an array of Person objects andPerson confirm to the ConsistencyManagerModel protocol.
Now how can i get updates when one of them changes?
I looked at the docs and the sample app, it seems that the sample app uses a parent model for that, but i prefer not to do it.
I also read about the BatchListener but i didn't understand how to use it.
thanks

Want to make a Swift 4 fix

@plivesey Hope all is well! Think I can get ownership on this repo so I can continue to maintain it or at least find some other maintainers here? Thanks!

Swift 4 Support

Beware, this project compiles without errors as Swift 4, but crashes at runtime because of missing @objc in methods like applicationDidReceiveMemoryWarning.

Running the migrator would probably fix this.

BTW, this is not actually this library's fault as it is explicit in the readme that it's a Swift 3 library, but rather a symptom of CocoaPods/CocoaPods#7134.

Current master commit does not build

I am attempting to use this, with RocketData, in a Swift 3 based project with Xcode 8. I am referring my cart file to the master branch to get the latest (for now). My project is an iOS project, setup for universal and configured to run on the simulator.

When running carthage update I get this:

*** Checking out ConsistencyManager-iOS at "5ed13ecc9d3492dc08ce6c6787d705ea708ee226" *** Building scheme "ConsistencyManager" in ConsistencyManager.xcodeproj Failed to write to /Users/aname/Documents/Project/Carthage/Build/Mac/ConsistencyManager.framework: Error Domain=NSCocoaErrorDomain Code=260 "The file “ConsistencyManager.framework” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/aname/Library/Developer/Xcode/DerivedData/ConsistencyManager-fearqdlqpzasxjgmoxazbykbsxxj/Build/Products/Release-iphoneos/ConsistencyManager.framework, NSUnderlyingError=0x7fc8bc70a9c0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Notice that the error is about a build for Mac (it refers to Carthage/Build/Mac), whereas I only need a build for iOS. I can get around that with --platform iOS, but IMHO this error should not happen.

2.0.0 Release

We are in the middle of adding support for projections which will likely require a major bump of the library. This will allow people the ability to have different classes with the same ID.

If anyone has any other feature requests, we should probably include them in this release.

Current list:

  • Add support for projections
  • Ensure pausing, batching and other features also work with projections
  • Add unit tests to all features for projections
  • Add ability to clear the consistency manager (cancel all tasks and wipe listeners)
  • Add docs for projections

Swift 3 API for BatchListener could use some work

open func addListener(_ consistencyManager: ConsistencyManager)
open func listenerHasUpdatedModel(_ listener: ConsistencyManagerListener, consistencyManager: ConsistencyManager)

aren't great and don't read that well at the callsite.

Potential for race condition when accessing `listeners` dictionary?

Thanks for sharing this! It's certainly an interesting idea.

Looking over the code it appears that the listener dictionary is being accessed both from the mainQueue and the libraries dispatchQueue.

Since Swift properties & data structures are not thread safe I see a potential cause for race conditions - or am I missing something?

Thanks again for sharing!

Threading

Hello, @plivesey, thank you for the library!
Why does any work with addModelUpdatesListener and removeModelUpdatesListener should be done on main thread?
https://github.com/plivesey/ConsistencyManager-iOS/blob/master/ConsistencyManager/ConsistencyManager.swift#L416

I ask because I have an intention to write through the RocketData's provider setData(...) using background thread, and there is some logic around llisteningToModelIdentifier property. And so I have some crashes because array modelUpdatesListeners out of sync https://github.com/plivesey/ConsistencyManager-iOS/blob/master/ConsistencyManager/ConsistencyManager.swift#L102 .
On the other hand there is similar listeners array, and ConsistencyManager synchronize access through internal queue using dispatchTask(...).

Is there some valuable reason to access model updates listeners on main thread only?
If not I propose to use dispatchTask in similar way as work with listeners array. I can do a PR.

Thank you!

Redo the Weak array stuff so that we don't have to copy so much code

This conversation is what prompted this:

nicksnyder 17 hours ago LinkedIn member

Is there something that prevents us from doing Array<WeakHolder<Protocol>>

If that doesn't work then Array<WeakHolderForProtocolA>

Implementing WeakHolderForProtocolA, WeakHolderForProtocolB, ... etc would be much simpler than reimplementing the entire array API for each protocol.

plivesey 17 hours ago LinkedIn member

The first is impossible because you can't use protocols as generics. The second sounds like a pretty good idea and yeah, I think this is probably the way to go.

Reminds me of AnySequence and AnyError. Basically, we want weak type-erased classes to hold these protocols.```

Add support for projections

Allow for different classes to have the same ID. They should be merged together when updates to one class affects another.

If you don't use projections, there should be no code change.

Add the ability to listen to arbitrary model changes

Currently, you can only listen to a model already in the system. It'd be great to be able to listen to models not yet added to the system. This allows two things:

Solution to: plivesey/RocketData#50
Ability to do predicate like things on collections (listen to all models of a certain class and add them to your collection if they match some criteria)

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.