CentreForDigitalHumanities / backbone-util

Various utilities for Backbone applications
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

@uu-cdh/backbone-util

Various utilities for Backbone applications.

Rationale | Quickstart | Compatibility | Reference | Planned | Support | Development | BSD 3-Clause

Rationale

We built several applications with a Backbone client. While writing those clients, we found ourselves repeating small patterns that were not yet abstracted by Backbone itself. We factored out those patterns and bundled them in this package, so that you can reuse them in your own Backbone single-page applications (SPAs). All of these utilities are small, independent additions to what Backbone can already do:

These utilities are well tested and we believe most Backbone applications can use at least a few of them.

We provide prototype mixins, rather than full-blown constructors/classes, because this gives you the freedom to layer them on top of a custom base class. This also leaves the choice up to you whether you want to use classic Backbone.*.extend() syntax or the modern class/ super keywords. We even have some tips in case you want to combine Backbone with TypeScript.

Quickstart

We recommend a workflow in which you install dependencies from npm and bundle them with a tool such as Rollup.

// could also use yarn, pnpm, etcetera
npm add @uu-cdh/backbone-util
import { View } from 'backbone';
import { getAltClickMixin } from '@uu-cdh/backbone-util';

export var MyBaseView = View.extend(getAltClickMixin());
// (See the reference for all the possible ways to use the library.)

You can also use the library directly from a browser embed, but you may need to set up import maps in that case.

Compatibility

The code modules use modern import/export syntax. If your target environment does not support this, you will need to take the code through a conversion or bundling tool first. Otherwise, only syntax is used that has existed for a while, so no transpilation or polyfilling should be required.

Reference

Planned features

Support

Please report security issues to cdh@uu.nl. For regular bugs, feature requests or any other feedback, please use our issue tracker.

Development

Please see the CONTRIBUTING for everything related to testing, pull requests, versioning, etcetera.

License

Licensed under the terms of the three-clause BSD license. See LICENSE.