GitXplorerGitXplorer
L

DataLoader

public
8 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
19459f8fe86b09c93c9fecc820fb60e127293756

Update README.md

LLucianoPAlmeida committed 6 years ago
Verified
6ce405c0f8a642db05e86f466fea6892f82c07f0

Merge pull request #3 from LucianoPAlmeida/result-type

LLucianoPAlmeida committed 6 years ago
Unverified
686175ddf8026041b685de19edb341df67fe6b29

0.3.0

LLucianoPAlmeida committed 6 years ago
Verified
0dffd535e5ec6ed1b5df67809ff7466608707a20

Merge pull request #2 from LucianoPAlmeida/result-type

LLucianoPAlmeida committed 6 years ago
Unverified
89800ef19ea7461f02cb865affce9e9dff722751

Travis fix

LLucianoPAlmeida committed 6 years ago
Unverified
171e6445356113d14156fd26f6cada4b1d19c221

Refator to use result type

LLucianoPAlmeida committed 6 years ago

README

The README file for this repository.

DataLoader

license Travis Codecov codebeat badge Twitter

This is a key/value memory cache convenience library for Swift.With DataLoader you can mantain your data loaded cached during an operation that sometimes requires you manage the state loaded and not loaded.

Inspired on the opensource facebook/dataloader library.

Instalation

Carthage

     github "LucianoPAlmeida/DataLoader" ~> 0.3.0  

CocoaPods

       pod 'DataLoader', '~> 0.3.0'     

Usage

   var loader: DataLoader<Int, Int>!
   // Creating the loader object.
   loader = DataLoader(loader: { (key, resolve, reject) in
       //load data from your source (can be a file, or a resource from server, or an heavy calculation)
       Fetcher.data(value: key, { (value, error) -> Void in 
           if let error = error {
               reject(error)
           } else {
               resolve(value)
           }
       })
   })
   
   //Using the loader object. 
   loader.load(key: 6) { (result) in
     //do your stuff with data
   }
   
   //Clear data from cache
   loader.cache.remove(key: 6) 
   
   //or 
   
   loader.cache.clear()
   

Licence

DataLoader is released under the MIT License.