Giter VIP home page Giter VIP logo

friend-list's Introduction

Friend List

A non-trivial (yet simple) front-end programming challenge. Featuring solutions in React, Redux, Redux-Saga, Cycle.js, Motorcycle.js and Snabbdom.

Check out the Elm solution here!

alt tag

The Problem

Create an app with a dynamic and search-able list of data that keeps a search input text query in sync with the URL via a query parameter at all times. Assume the data will be fetched from some API and the API will perform the actual search. The query should be a simple string and kept in sync with the URL via a query parameter 'q' (ex. localhost:3000/?q=batman).

This problem is harder than it first appears, actions must be managed in the correct order, and if not can result in infinite loops and other undesirable behavior.

The Spec

  • Hit the API once and only once per query change.
  • When the query updates -> update the URL and fetch results from the API.
  • When the URL updates -> update the query and fetch results from the API.
  • The browser's back / forward buttons should keep the app state (query + results) in sync with the URL (this is a gotcha if not thought about carefully).

Bonus Features

  • Handle the concurrent actions issue (see the redux-saga-solution, the cyclejs-solution, the motorcyclejs-solution, and the better-observable-solution) - "If the user changes the query input while there is still a pending request from a previous query change, the current pending request should be cancelled and a new request should be made." - Thanks @yelouafi
  • Debounce the fetching of results by 100ms.
  • Log any state changing action with the newly changed state.
  • Add loading and/or error states (see the redux-meta-reducer friend-list example).

Solutions

Solutions are in their own subdirectories above. Check out the README files in each of the subdirectories for example specific details.

Many have similar structures (identical store state + hitting the same mock API). The difference being when and where the apps read router state and when and where the apps dispatch actions.

To run

First clone the repo.

git clone https://github.com/DerekCuevas/friend-list.git

Then cd into an example, 'npm install' and 'npm start' to get going.

cd friend-list/imperative-solution/ # or the others
npm install
npm start

Contributors

Have a better implementation?

Please make an issue or send in a pull request.

friend-list's People

Contributors

derekcuevas avatar tylors avatar yelouafi avatar justinwoo avatar prayagverma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.