Skip to content

Instantly share code, notes, and snippets.

View AakashRaina's full-sized avatar
🎯
useCode()

Aakash Raina AakashRaina

🎯
useCode()
View GitHub Profile
class ProgressiveImage extends React.Component {
constructor(props) {
super(props);
this.placeholderAnimated = new Animated.Value(0);
this.imageAnimated = new Animated.Value(0);
}
handlePlaceholderLoad = () => {
Animated.timing(this.placeholderAnimated, {
toValue: 1
// The classic AJAX call - dispatch before the request, and after it comes back
function myThunkActionCreator(someValue) {
return (dispatch, getState) => {
dispatch({type : "REQUEST_STARTED"});
myAjaxLib.post("/someEndpoint", {data : someValue})
.then(
response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}),
error => dispatch({type : "REQUEST_FAILED", error : error})
);
@AakashRaina
AakashRaina / System Design.md
Created April 13, 2018 09:24 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@AakashRaina
AakashRaina / eager-prefetching-async-data-example.js
Created April 10, 2018 16:19 — forked from bvaughn/eager-prefetching-async-data-example.js
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};
import React, { Component } from 'react';
// Create a context first of all //
const MyContext = React.createContext();
// Make a component class which returns the context using a provider //
class MyContextProvider extends Component {
constructor(props) {
super(props);
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}
@AakashRaina
AakashRaina / introrx.md
Created October 1, 2017 18:23 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing