Code Monkey home page Code Monkey logo

vue-pure's Introduction

vue-pure

This is an example of using Purescript to handle business logic in a Vue application. It uses purs-loader to incorporate Purescript compilation into the webpack build.

Advantages

  • All the benefits of static-typing, purity, and controlled effects
  • Redux debug tools
  • Vue ecosystem and tooling

Setup

The actions, state, and reducers are written in Purescript. They can be found in the state directory. Connecting this to Redux is done in state/store.js:

  • Each reducer is applied to uncurryReducer, which catches the initialization case (where state is undefined), by calling the rootReducer with an initialAction.
  • standardizeAction intercepts incoming actions to assign them a name (following "flux-standard-action")

Dispatching

Each smart component has a corresponding .purs file that will handle mapping the state and dispatch to props. An example is components/Counter/Counter.purs, where the state and actions are exposed. Action creators are placed in their corresponding Action.purs file and can be invoked inside mapDispatchToProps.

Why not Vuex?

Unfortunately, Vuex is not a good candidate for purescript interop because it depends on mutability. Purescript has no concept of mutability and this would require mapping immutable state updates to the Vuex state. Although not impossible, it does present a performance concern as well as hindering reducer composition.

Developing

Project setup

yarn install
spago install

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build

Run your tests

yarn run test

Lints and fixes files

yarn run lint

Customize configuration

See Configuration Reference.

vue-pure's People

Contributors

sliptype avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-pure's Issues

Asynchronous example

It would be helpful to show an example of an api call in a purescript action creator

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.