Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

choo-conductor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-conductor

Dead simple routing 'plugin' for Choo that simplifies views and loads data for you automatically. No dependencies!

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Conductor

Dead simple routing 'plugin' for Choo that simplifies views and loads data for you automatically. No dependencies!

Depends on choo PR#553, but you can use jonjaques/choo#feature/add-route-event in the meantime.

Currently does two things:

  1. Allows you to use a layout view which wraps all child views
  2. Views can define a loadData(state, emit) member which is called on page load and on route events (added by PR referenced above)
const app = Conductor(Choo)()

// app.use some stuff
app.layout(layout)
app.routes({
  '/'          : homepage,
  '/todos'     : todoList,
  '/todos/:id' : todoDetail
})
app.mount('#application')

function todoList(state, emit) {
  return html`...`
}

todoList.loadData = function(state, emit) {
  emit('todos.load')
}

function todoDetail(state, emit) {
  return html`...`
}

todoDetail.loadData = function(state, emit) {
  emit('todos.loadDetail', state.params.id)
}

function layout(view, state, emit) {
  return html`
    <div id="global-layout">
      <header />
      ${view(state, emit)}
      <footer />
    </div>
  `
}

FAQs

Package last updated on 31 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc