redux-capi

redux-capi

    ›Introduction

    Introduction

    • What it is
    • Usage
    • Rationale
    • Context

    API Specs

    • API Spec
    • Redactions
    • Selectors
    • Thunks
    • Mounting
    • Composing
    • Validation

    Reference

    • createAPI
    • API
    • api.mount()
    • api.mock()
    • Injection
    • Utilities

    Examples

    • Todo List

    Rationale for redux-capi

    When redux was integrated into React with redux-react the primary integration vehicle was the High Order Component (HOC) which was "connected" to the redux store. As part of that connection actions and selectors were pushed into properties and these properties fed to the lower order component. With the advent of hooks this concept became inoperative and instead selectors and dispatchable actions were defined within the actual visual component. In doing so this increased the coupling between "logic" and visual rendering.

    redux-capi fully isolates logic from visual rendering. And unlike HOCs which are bound to their lower level component they can be reused. The API may contain the complete logic surrounding a subject area and be consumed by many different components each of which may consume only the portion that they need. The magic to making this work is that the selectors are in fact getters. This allows redux-capi to track which selectors are used by which component and only force a re-render of the affected components.

    redux-capi has attempted to address some of the pain points of redux-react while building on the fundemental advantages of reducers and immutability.

    Pain PointSolution
    Substantial boiler plate code requiredDeclarative constructs reduce boiler plate by automating actions and reducers
    Global name space for action namesAction names are scoped within a specific API
    Application logic embedded in componentsApplication logic contained in API implementation rather than in an HOC or function-based component.
    Presentation and logic tested togetherVisual components and logic (API) can be tested independently
    Composition and re-use (splitting reducer logic) requires significant coordinationAPI specs are largely independent and can be combined and mapped to different parts of the state shape
    ← UsageContext →
    redux-capi
    Docs
    Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
    Community
    User ShowcaseStack OverflowProject ChatTwitter
    More
    BlogGitHubStar
    Facebook Open Source
    Copyright © 2020 Sam Elsamman