BreakOutEvent / breakout-ios

BreakOut – As far away as possible. Two people. No money. 36 hours. – For the UNHCR.
http://break-out.org
5 stars 2 forks source link

Refactor Model #97

Closed nerdsupremacist closed 7 years ago

nerdsupremacist commented 7 years ago

Let's be careful about this one!

This is a major change to our model, API calling, and well... just about everything.

@dsymhoven I strongly recommend that we merge any changes you made before, because this branch will most certainly break something. Fixing them here will be waaaay easier ;) than the other way around.

So! What's new?

Well, there's no more BONetworkManager, BOSynchronizeManager or any of those. We are no longer caching anything!

The model we gather from the API was completely reimplemented (it was easier that way). I'm only talking about what we get from the API, so all classes like MapLocation are intact.

The big changes are:

Post.all().onSuccess { posts in
    // Do something with your postings
}

We can also add error handling with:

Post.all().onSuccess { posts in
    // Do something with your postings
}
.onError { error in
    // Handle Error
}

There's of course more complex calls like:

Post.all(since: id).onSuccess { posts in
    // Do something with your postings
}
Post.post(text: message, latitude: latitude, longitude: longitude, media: [image]).onSuccess { post in
    // Do something with your post
}

The rest of the classes follow more or less this same schema.

This means that we can observe these and get notifications when something changes. To get updates you can simply call:

import Sweeft

/// REST of your code

observableItem >>> {  updatedItem in
    // Refresh any UI concerning this item
}

This PR also comes with a few extra features:

And scraps the following dependencies:

And added:

Dependencies that might be dropped later:

thepiwo commented 7 years ago

minor refactoring

nerdsupremacist commented 7 years ago

I will merge this. I want to test the deploy script