Skip to content

Instantly share code, notes, and snippets.

@johndelong
johndelong / SwiftUI.md
Last active November 16, 2021 21:58
General notes on the core components of SwiftUI

@ObservedObject / @Published

The ObservableObject conformance allows instances of a class to be used inside views, so that when important changes happen the View will reload.

The @Published property wrapper tells SwiftUI that changes to a property should trigger View reloads.

class Contact: ObservableObject {
    @Published var name: String
 @Published var age: Int
@kaushikgopal
kaushikgopal / android_lifecycle_recommendations.md
Last active February 2, 2022 07:28
Notes on opportune moments to do "stuff" in the Android Lifecycle
  • In general you want to try and put things in onStart and onStop for logical start and stops.

Activity

onCreate

  • Dagger inject self into graph
  • setContentView(R.layout.xxx)
  • Butterknife.bind(this)
  • RxJava CompositeSubscription.add (if NON UI related work being done)
  • realm = Realm.getDefaultInstance();
@alex-shpak
alex-shpak / Interceptor.java
Last active March 29, 2023 21:06
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON