kienstra / no-app-state

An app with no state, just functions calling functions

Home Page:https://ryankienstra.com/no-state-means-almost-no-internal-dependency/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No App State

Thanks to Logicroom.co for the test cases, stubs, and React components in this repo.

This is a Functional Programming take on the Logicroom ideas.

What if there was no app state…

Only a single data object?

There would be almost no internal dependency.

And unit testing would be really easy.

This is like Redux.

But we won't test Redux or React.

Only the reducer functions:

describe('init', () => {
  it('inits app', async () => {
    const httpGateway = new StubHttpGateway()
    const routerGateway = new StubRouterGateway()
    routerGateway.registerRoutes = vi.fn()

    await makeReducers(httpGateway, routerGateway)(
      initialState,
      { type: 'INIT' }
    )

    expect(routerGateway.registerRoutes).toHaveBeenCalledOnce()
  })
})

About

An app with no state, just functions calling functions

https://ryankienstra.com/no-state-means-almost-no-internal-dependency/


Languages

Language:JavaScript 97.3%Language:CSS 1.6%Language:HTML 1.0%