GithubHelp home page GithubHelp logo

vexy / fridge Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 0.0 52.97 MB

Handle your structs like a boss ๐Ÿงžโ€โ™‚๏ธ

License: MIT License

Swift 100.00%
fridge downloader background vexy swift codable struct storage async await

fridge's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fridge's Issues

Retrieve all existing object identifiers.

This might be useful during

  • development - want to clean up my mess :)
  • when migrating data - get existing structures and convert them to new ones.
  • data structure validation - when data is important

Updating models?

What happens when a model gets updated?

It seems that Fridge fails to unfreeze existing data into a new structure. I see two cases here:

  1. extended model (e.g., new field added): I expected this to work when a new field has a default value.
  2. modified model (e.g., existing fields changes type etc): this is ok to fail.

One idea is to catch errors on load and then try to import data by first loading them into a generic dictionary/map (whatever is available on swift) and then manually importing data into the new, extended structure. This process could also give a mapping callback that could be used in case of modified fields (e.g. (fieldName, oldValue) -> newValue)

Hashed storage

Provide a method for saving/retreiving hashed transformation of given struct.

Refactor tests

Merge or combine the tests.

There's no real difference in functional testing.

Update BSONCoder?

Got this warnings while building:

'NIOAtomic' is deprecated: please use ManagedAtomic from https://github.com/apple/swift-atomics instead

Simple App usage examples

Demonstrate few Xcode example projects and the way how Fridge can be used:

  • Github repos simple app
  • Link Clmn app as usage example

Remove unneeded debug outputs

  • Freezer

} catch {
print("THROW HAPPENED")
throw FreezingErrors.dataReadingError
}

  • BSONConverter

// now flush the data to a file
print("Writing to: \(_rawFilePath)")
try rawBSONData.write(to: _rawFilePath)

// prepare input stream
let rawBSONData = try Data(contentsOf: _rawFilePath)
print("Reading from: \(_rawFilePath)")

Add `push` method

Add a method that can push (send) given object to a certain URL.

Object must confirm to Codable.

If the passed object fails to be parsed to JSON the method will throw.

Add `adjust` method

Add a public method that allows changing field value of an already frozen struct without the need for unfreezing.

New value should be present at next unfreeze attempt.

eg:

try Fridge.adjust(FrozenStruct.Self, field: \.field1, value: 10)

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.