Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

DroidsOnRoids/StructPersistence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a finished project described in blogpost here. For more details, context, motivation and more please check it out!

Used pods:

Used library:

Usage

You declare what template you want to apply on a struct with //sourcery: templateOne, templateTwo, etc:

//sourcery: NSCodingWrapper, RealmStruct, CoreDataStruct
struct Shot {
    let id: Int
    let url: String
    let likes: Int
    let comments: Int
    let buckets: Int
    let views: Int
}

To launch codegen you need to run Sourcery via:

$ ./sourcery --sources <sources path> --templates <templates path> --output <output path> [--args arg1=value,arg2]

For more info please check out the Sourcery repo.

Sidenotes

The purpose of this project is:

  • how to supercharge your work by using code generation with Sourcery
  • increase abstration and separate dependency from persistence type
  • give a sense how you could use Sourcery for other useful cases where boilerplate code are necessary

I'm NOT showing here:

  • how to effeciently store JSONs with CoreData/Realm 😅
  • how to use CoreData/Realm as cache(since it's ridiculous idea)
  • utilizing caching method from external libary(like Haneke, just used for images for ease of use. We could surely store images as Data, but that's not the goal here.)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published