Skip to content

Instantly share code, notes, and snippets.

View adnaan's full-sized avatar
🎯
Focusing

Adnaan Badr adnaan

🎯
Focusing
View GitHub Profile
import {createSlice} from "@reduxjs/toolkit";
import {asyncThunk, rx, asyncAction} from "./thunks";
import {identity} from "./identity";
export const fetchAccount = asyncThunk(
"account",
"fetchAccount",
async (id, state) => {
return identity.currentUser().attributes();
});
{
"labels": ["January", "February"],
"datasets": [{
"label": "Data One",
"backgroundColor": "#f87979",
"data": [40, 20]
}]
}
@adnaan
adnaan / centrifuge-react-native.jsx
Last active August 16, 2021 13:53
Centrifuge Client example for react native
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Centrifuge from 'centrifuge';
export default class App extends React.Component {
componentDidMount() {
console.log("componentDidMount")
var timestamp = Math.floor(Date.now() / 1000);
var centrifuge = new Centrifuge({

Keybase proof

I hereby claim:

  • I am adnaan on github.
  • I am adnaan (https://keybase.io/adnaan) on keybase.
  • I have a public key ASAgzL2uEUiEMnnqLkRbqECnLs5vet2p2FQF23eFrf45HAo

To claim this, I am signing this object:

@adnaan
adnaan / dep.go
Created July 7, 2017 03:42
Global Dependency
package main
// Using a global dependency
var userService user.Service
func Init() {
userService = user.NewService()
}
func GetComments() []Comment {
var comments []Comment
/*@flow*/
import React from 'react';
import ProductList from './components/ProductList'
import { connect } from 'react-redux';
const App = connect(({ products }) => ({
products
}))(function(props) {
return (
<div >
/*@flow*/
import React from 'react';
import Product from './Product';
function ProductList(props: { data: Array < { ID: number, title: string, vote: number } > , dispatch: Function }) {
return (
<div >
{
props.data.map(product => <Product
key={product.ID}
@adnaan
adnaan / Product.js
Last active November 6, 2016 09:46
/*@flow*/
import React from 'react';
import FaCaretUp from 'react-icons/lib/fa/caret-up';
function Product(props: { id: number, title: string, vote: number, dispatch: Function }) {
const { id, title, vote } = props;
function handleVote() {
props.dispatch({
type: 'products/vote',
@adnaan
adnaan / index.js
Created November 2, 2016 05:00
src/index.js
/*@flow*/
import React from 'react';
import { Router, Route } from 'dva/router';
import dva from 'dva';
import App from './App';
import model from './model';
import './index.css';
const app = dva();
app.model(model);
@adnaan
adnaan / model.js
Last active November 6, 2016 10:04
src/model.js
import { getProducts, updateVote } from './services';
export default {
namespace: 'products',
state: {
list: [],
loading: false,
},
subscriptions: {
init({ dispatch }: { dispatch: Function }) {