Skip to content

Instantly share code, notes, and snippets.

@cdl
Last active January 30, 2016 02:41
Show Gist options
  • Save cdl/2499e2534ad4d4c9bc20 to your computer and use it in GitHub Desktop.
Save cdl/2499e2534ad4d4c9bc20 to your computer and use it in GitHub Desktop.
import Nimble from 'nimble';
export default Nimble.Plugin.extend({
/**
* request: Returns a Promise that resolves with a search response, or rejects with an error.
* @attr term – The search term given.
**/
request(term, function() {
// ... return the promise
}),
deserializeResults(results, function() {
// do shit to the results and return
// the context you wish to use in the template (Object)
}),
renderTemplate(results, function() {
// return a serialized a template (uses Handlebars or some shit idk)
// that's displayed as the "results" on a successful result
}),
deserializeError(error, function() {
// deserialize the resolution of the Error from the request
}),
renderError(error, function() {
// return a template (Handlebars or some shit) that should be
// displayed as the "results" on a failing result (this defaults to
// `false` by default which shows the default Nimble error)
})
});
{
"name": "Example Plugin",
"author": "Colby Ludwig <[email protected]>",
"description": "An example plugin for Nimble.",
"url": "https://ldwg.me/example",
"tags": ["search", "plugin", "example]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment