New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

derby-load

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

derby-load

Derby plugin for direct route component matching, using component's load fn to do route tasks

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

derby-load

Derby plugin for direct route component matching, using component's load fn to do route tasks

How to use

In your app's base file (index.js in app root), activate the plugin in a non-Derby-standard way:

require('derby-load')(app);

Then, use route methods either as usual, e.g.:

app.get(pattern, callback);

Or, directly binded to a component (which has NOT previously been added using app.component)

app.get(pattern, require('myComponent'));
// or
app.get(pattern, require('myComponent'), {viewName: 'someViewName', ns: 'namespace to be passed into page.render'});

In your component, you can add a (optional) load fn to load things before page.render is called, e.g.:

MyComponent.prototype.load = function (page, model, params, next) {
  // Do some data fetching before render
  model.fetch('data', function () {
    page.render(); // Will automatically trigger the proper rendering. If ns i passed in, it will override the default ns (which corresponds to the view associated with the component - see below)
  });
};

Notes:

  • app.get will automatically bind the component upon initialization of the app
  • When the route gets triggered, it will automatically render the component
  • The component needs to have a view specified, if not the viewName options attribute is passed along:
MyComponent.prototype.view = 'myView'

Adds the possibility to add a subcomponents on your Component prototype - i.e. without access to app. E.g.

// When this component is loaded through app.component('./mycomponent/index.js'), the subcomponent will automatically be loaded namespaced to the maincomponents name (and possible namespace), i.e. you will have two components loaded (from below component):
// maincomponent
// maincomponent:subcomponent
function MyComponent () {}

MyComponent.prototype.name = 'maincomponent'
MyComponent.prototype.components = [require('subcomponent')]

Keywords

FAQs

Package last updated on 09 Jun 2015

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