How to use redoodle - 10 common examples

To help you get started, we’ve selected a few redoodle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ia-toki / judgels / judgels-frontends / raphael / src / modules / session / sessionReducer.ts View on Github external
import { setWith, TypedAction, TypedReducer } from 'redoodle';

import { User } from '../../modules/api/jophiel/user';

export interface SessionState {
  isLoggedIn: boolean;
  token?: string;
  user?: User;
}

// Somehow redux-persist won't work after dispatching DelSession if the next state is an empty object...
export const INITIAL_STATE: SessionState = { isLoggedIn: false };

export const PutToken = TypedAction.define('session/PUT_TOKEN')();
export const PutUser = TypedAction.define('session/PUT_USER')();
export const DelSession = TypedAction.defineWithoutPayload('session/DEL')();

const createSessionReducer = () => {
  const builder = TypedReducer.builder();

  builder.withHandler(PutToken.TYPE, (state, payload) => ({
    isLoggedIn: true,
    token: payload,
  }));
  builder.withHandler(PutUser.TYPE, (state, payload) => setWith(state, { user: payload }));
  builder.withHandler(DelSession.TYPE, () => INITIAL_STATE);
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
};
github ia-toki / judgels / judgels-frontends / raphael / src / modules / session / sessionReducer.ts View on Github external
import { setWith, TypedAction, TypedReducer } from 'redoodle';

import { User } from '../../modules/api/jophiel/user';

export interface SessionState {
  isLoggedIn: boolean;
  token?: string;
  user?: User;
}

// Somehow redux-persist won't work after dispatching DelSession if the next state is an empty object...
export const INITIAL_STATE: SessionState = { isLoggedIn: false };

export const PutToken = TypedAction.define('session/PUT_TOKEN')();
export const PutUser = TypedAction.define('session/PUT_USER')();
export const DelSession = TypedAction.defineWithoutPayload('session/DEL')();

const createSessionReducer = () => {
  const builder = TypedReducer.builder();

  builder.withHandler(PutToken.TYPE, (state, payload) => ({
    isLoggedIn: true,
    token: payload,
  }));
  builder.withHandler(PutUser.TYPE, (state, payload) => setWith(state, { user: payload }));
  builder.withHandler(DelSession.TYPE, () => INITIAL_STATE);
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
};

export const sessionReducer = createSessionReducer();
github ia-toki / judgels / src / routes / uriel / competition / routes / contests / modules / contestReducer.ts View on Github external
function createContestReducer() {
  const builder = TypedReducer.builder();

  builder.withHandler(PutContest.TYPE, (state, payload) => ({ value: payload }));
  builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
}
github ia-toki / judgels / judgels-frontends / raphael / src / routes / contests / contests / modules / contestReducer.ts View on Github external
import { setWith, TypedAction, TypedReducer } from 'redoodle';

import { Contest } from '../../../../modules/api/uriel/contest';

export interface ContestState {
  value?: Contest;
  isEditing?: boolean;
}

export const INITIAL_STATE: ContestState = {};

export const PutContest = TypedAction.define('uriel/contest/PUT')();
export const DelContest = TypedAction.defineWithoutPayload('uriel/contest/DEL')();
export const EditContest = TypedAction.define('uriel/contest/EDIT')();

function createContestReducer() {
  const builder = TypedReducer.builder();

  builder.withHandler(PutContest.TYPE, (state, payload) => setWith(state, { value: payload }));
  builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
  builder.withHandler(EditContest.TYPE, (state, payload) => setWith(state, { isEditing: payload }));
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
}

export const contestReducer = createContestReducer();
github ia-toki / judgels / judgels-frontends / raphael / src / routes / contests / contests / modules / contestReducer.ts View on Github external
import { setWith, TypedAction, TypedReducer } from 'redoodle';

import { Contest } from '../../../../modules/api/uriel/contest';

export interface ContestState {
  value?: Contest;
  isEditing?: boolean;
}

export const INITIAL_STATE: ContestState = {};

export const PutContest = TypedAction.define('uriel/contest/PUT')();
export const DelContest = TypedAction.defineWithoutPayload('uriel/contest/DEL')();
export const EditContest = TypedAction.define('uriel/contest/EDIT')();

function createContestReducer() {
  const builder = TypedReducer.builder();

  builder.withHandler(PutContest.TYPE, (state, payload) => setWith(state, { value: payload }));
  builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
  builder.withHandler(EditContest.TYPE, (state, payload) => setWith(state, { isEditing: payload }));
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
}

export const contestReducer = createContestReducer();
github ia-toki / judgels / judgels-frontends / raphael / src / routes / contests / contests / modules / contestWebConfigReducer.ts View on Github external
import { TypedAction, TypedReducer } from 'redoodle';

import { ContestWebConfig } from '../../../../modules/api/uriel/contestWeb';

export interface ContestWebConfigState {
  value?: ContestWebConfig;
}

export const INITIAL_STATE: ContestWebConfigState = {};

export const PutWebConfig = TypedAction.define('uriel/contest/web/PUT_CONFIG')();
export const DelWebConfig = TypedAction.defineWithoutPayload('uriel/contest/web/DEL_CONFIG')();

function createContestWebConfigReducer() {
  const builder = TypedReducer.builder();

  builder.withHandler(PutWebConfig.TYPE, (state, payload) => ({ value: payload }));
  builder.withHandler(DelWebConfig.TYPE, () => ({ value: undefined }));
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
}

export const contestWebConfigReducer = createContestWebConfigReducer();
github ia-toki / judgels / judgels-frontends / raphael / src / routes / contests / contests / modules / contestReducer.ts View on Github external
import { setWith, TypedAction, TypedReducer } from 'redoodle';

import { Contest } from '../../../../modules/api/uriel/contest';

export interface ContestState {
  value?: Contest;
  isEditing?: boolean;
}

export const INITIAL_STATE: ContestState = {};

export const PutContest = TypedAction.define('uriel/contest/PUT')();
export const DelContest = TypedAction.defineWithoutPayload('uriel/contest/DEL')();
export const EditContest = TypedAction.define('uriel/contest/EDIT')();

function createContestReducer() {
  const builder = TypedReducer.builder();

  builder.withHandler(PutContest.TYPE, (state, payload) => setWith(state, { value: payload }));
  builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
  builder.withHandler(EditContest.TYPE, (state, payload) => setWith(state, { isEditing: payload }));
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
}

export const contestReducer = createContestReducer();
github ia-toki / judgels / src / routes / uriel / competition / routes / contests / modules / contestReducer.ts View on Github external
import { TypedAction, TypedReducer } from 'redoodle';

import { Contest } from '../../../../../../modules/api/uriel/contest';

export interface ContestState {
  value?: Contest;
}

export const INITIAL_STATE: ContestState = {};

export const PutContest = TypedAction.define('uriel/contest/PUT')();
export const DelContest = TypedAction.defineWithoutPayload('uriel/contest/DEL')();

function createContestReducer() {
  const builder = TypedReducer.builder();

  builder.withHandler(PutContest.TYPE, (state, payload) => ({ value: payload }));
  builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
}

export const contestReducer = createContestReducer();
github ia-toki / judgels / judgels-frontends / raphael / src / routes / contests / contests / modules / contestReducer.ts View on Github external
  builder.withHandler(PutContest.TYPE, (state, payload) => setWith(state, { value: payload }));
  builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
github ia-toki / judgels / judgels-frontends / raphael / src / modules / session / sessionReducer.ts View on Github external
const createSessionReducer = () => {
  const builder = TypedReducer.builder();

  builder.withHandler(PutToken.TYPE, (state, payload) => ({
    isLoggedIn: true,
    token: payload,
  }));
  builder.withHandler(PutUser.TYPE, (state, payload) => setWith(state, { user: payload }));
  builder.withHandler(DelSession.TYPE, () => INITIAL_STATE);
  builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));

  return builder.build();
};