Skip to content

YerkoPalma/choo-genesis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<%= projectName %> built with choo v3

Offline first choo app for designers and web developers

Features

(*) Because all the work to make it offline first happen without your intervention, is all automatic thanks to npm build scripts and choo offline plugin

Usage

# start an http local server with livereload
$ npm run dev

# run tests
$ npm test

# generate production files in a dist/ folder
$ npm run build

Handling offline status

If you need to handle offline mode, there are some tricks that can help you with. There is an offline plugin that manipulate choo hooks and wrappers for offline support. One of that hooks is triggered whenever an action takes place, and has the responsability to trigger a backup function if there is no internet connection. To use this, you have to send a _backup string in your send data. This string should be the name of the action that you expect to get executed. So, your model and view should look like this:

const model = {
  state: {
    username: '',
    pass: ''
  },
  reducers: {
    logIn: (data, state) => data.user
  },
  effects: {
    connect: (data, state, send, done) => {
      send('logIn', { _backup: '_connect' }, done)
    },
    _connect: (data, state, send, done) => {
      send('logIn', {}, done)
    }
  }
}
const view = (state, send) => {
  return html`
    <button onclick=${(e) => send(
        'update',
        { payload: e.target.value, _backup: '_update' }
      )}></button>
  `
}

License

MIT © Yerko Palma

About

🌐 Custom choo template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published