npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

backbone-hypermedia

v0.4.4

Published

Backbone plugin providing support for following hypermedia controls from Backbone models and collections.

Downloads

5

Readme

Build Status Bower Version npm Version Nuget Version backbone.hypermedia

Backbone plugin providing support for following hypermedia controls from Backbone models and collections.

Basic Usage

Assuming a resource with a links property, something like this:

{
	"name": {
		"first" : "Joe",
		"last": "Bloggs"
    },
    "links" : [
    	{ "rel": "country", "href": "/countries/GB" }
    ]
}

Define a corresponding Backbone model by extending Backbone.HypermediaModel (instead of Backbone.Model):

var User = Backbone.HypermediaModel.extend({
   ...
});

Then define a links property for the model like this:

links: {
	'country': Country,
	'timezone': TimeZone
}

Each key corresponds to the rel value of a link which may be present when the model is fetched from the server. The value defines the type of Backbone model you would like to be constructed based on that relation, so in this example Country and TimeZone are Backbone models (which must themselves extend Backbone.HypermediaModel).

Backbone.HypermediaModel overrides fetch so that for each link found in the response, if there is a corresponding value in the links property on your model, then the related model will also be fetched and a property added to your model under the same key. The return value of fetch is a promise which represents the collective fetch operations for the model and all related resources.

By using the promise returned from fetch you can wait until all related resources are fetched before rendering your view:

user.fetch().then(function () {
	// show user view
});

You can also add a links property to each related resource and have those relations followed as well, if you need to.

toJSON will include any related models which have been added to your model as properties.

Installation

Bower Bower Version

bower install backbone-hypermedia

npm npm Version npm Downloads

npm install backbone-hypermedia

NuGet Nuget Version Nuget Downloads

Install-Package backbone.hypermedia

Publishing

Prior to publishing a new version of the package, you must run the following commands to configure your NuGet and npm credentials. You should only need to do this once.

npm adduser
grunt nugetkey --key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Once you have entered your credentials, you will have to get yourself added as a maintainer to both nuget and npm. Then you can publish to npm and NuGet by running one of the following tasks:

grunt publish:patch

Increments patch version in package.json, publishes to npm and NuGet. A short-hand command is grunt publish.

grunt publish:minor

As before, but bumps minor version.

grunt publish:major

As before, but bumps major version.

The publish task will create an appropriate semver tag which Bower will detect as a new version.

Contributors