Spread is a data flow control. It changes the way you manage your data.
- Create, mapping dictionary to model and model to dictionary, manage data model automatic.
- Auto trigger event to all models in register pools.
- React when model properties, pool change value.
- Store and restore models in pools from local database.
- Fetch/push data for model from internet.
- Remote event manager with queue.
pod "Spread", "~> 1.2.1"
- Drag and drop Classes folder into your project.
#import "Spread.h"
class Model: Mapper {
dynamic var objectId: String!
dynamic var name: String!
}
Spread.registerClass(Model.classForCoder(), forPoolIdentifier:"PoolIdentifier")
Spread.registerEvent("TheEvent",
poolIdentifiers:["PoolIdentifier"]) { (value, spool) -> Void in
let objectId = (value as NSDictionary).valueForKey("objectId") as String
let newName = (value as NSDictionary).valueForKey("name") as String
let models = spool.filter({ (model) -> Bool in
return (model as Model).objectId == objectId
})
for item in models {
let model = item as Model
model.name = newName
}
}
let model = Spread.addObject(["name": "Some name", "objectId": "123"],
toPool: self.pool1Identifier)
model.property("name", onEvent: .OnChange) { (oldValue, newValue) -> Void in
aTextField.text = newValue as String
}
Spread.outEvent("TheEvent",
value: ["name": "Change the name", "objectId": "123"])
If you use/enjoy Spread
, let me know!
See the LICENSE file for more info.