plivesey / consistencymanager Goto Github PK
View Code? Open in Web Editor NEWA library that manages consistency of immutable models
Home Page: https://plivesey.github.io/ConsistencyManager-iOS/
License: Apache License 2.0
A library that manages consistency of immutable models
Home Page: https://plivesey.github.io/ConsistencyManager-iOS/
License: Apache License 2.0
Could you please push the release 5.1.2 to Cocoapods repo? I cant updated it on https://github.com/linkedin/RocketData/ podspec file because the latest version there is 5.0.0
https://cocoapods.org/pods/ConsistencyManager
Thank you!!
-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.
Implemented in PR #25
Looks like dispatch_after in swift 3 has changed. We should probably add a test for this to verify.
To sphinx
Be able to cancel all tasks and wipe listeners. This is useful when logging out.
ConsitencyManager is best paired with 🚀 Data (which does support Carthage), but it would be great if folks could consume the framework directly via Carthage.
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
Seems like a better Swift 3 API, but missed the Swift 3 API train.
Possibly, let's include this in the next major version bump.
Need to do some work to get tests up and running.
From @nicksnyder:
One thing that I like about mkdocs is that there is a simple command to push to gh-pages. Looks like you can setup something similar with sphinx too:
http://nikhilism.com/post/2012/automatic-github-pages-generation-from/
@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!
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.
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.
Currently, they don't, but they should. Cancel all operations does not actually remove things from the queue so you need to check for cancellation.
See #8
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:
And create Contributing.md
open func addListener(_ consistencyManager: ConsistencyManager)
open func listenerHasUpdatedModel(_ listener: ConsistencyManagerListener, consistencyManager: ConsistencyManager)
aren't great and don't read that well at the callsite.
Now that the tests are running more frequently it seems that testRetainCycle()
from ListenerTests
fails in intermittent.
For now, I have disabled it and creating this issue so we don't forget why. For more see: #61
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!
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!
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.```
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.
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.