Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
jquery-atomic-nav
Advanced tools
Concise jQuery routing and navigation plugin based on nested navigation states.
Concise jQuery routing and navigation plugin based on nested navigation states.
This library is designed to work with component-based application UIs. Heavily inspired by the state-machine approach of AngularJS UI Router and modern techniques like Promises that emphasize immutable, functional state.
Unlike AngularJS UI Router and most other routing libraries, Atomic Nav routes are defined on-demand. This allows for a better, more elegant composition of widgets with no need for the massive central "routes" file.
Routes are defined via when
method. Each route body is executed when a navigation state is entered. The navigation state can be used to define nested routes, and to track when the user leaves that navigation state. The library defines the "root" navigation state that is always active - that is the starting place where routes are registered.
To detect when a navigation state is no longer active, register a callback on the state object using the whenDestroyed.then
method. The whenDestroyed
property is a full-fledged promise object, so the callback will be called even when trying to register after the user left the navigation state. This is helpful to easily clean up UI created as a result of an asynchronous operation: the operation may complete after the navigation state has become inactive, so attaching a simple event listener would miss out on the cleanup.
For more examples see /example/index.html
.
Example code:
var rootNav = $.navigationRoot();
rootNav.when('/foo', function (fooNav) {
console.log('entered "foo" state');
// e.g. create a container widget
fooNav.whenDestroyed.then(function() {
console.log('left "foo" state');
// e.g. destroy the container widget
});
fooNav.when('/bar', function (barNav) {
console.log('entered "foo/bar" state');
// e.g. create a sub-widget and attach to container
barNav.whenDestroyed.then(function() {
console.log('left "foo/bar" state');
// e.g. destroy the sub-widget
});
});
});
rootNav.when('/baz/:someParam', function (someParam, bazNav) {
console.log('entered "baz" state with "' + someParam + '"');
bazNav.whenDestroyed.then(function() {
console.log('left "baz" state with "' + someParam + '"');
});
});
Composition example:
// top-level "page" view
function RootView() {
var rootNav = $.navigationRoot();
var $dom = $('body');
rootNav.when('/fizz-buzz', function (fizzBuzzNav) {
var fizzBuzzView = new FizzBuzzView($dom, fizzBuzzNav);
});
}
// sub-component in another file
function FizzBuzzView($dom, nav) {
// ... render DOM, etc
// can create sub-routes without needing to know what the URL is
nav.when('/foo-bar', function (fooBarNav) {
// render more sub-route DOM, etc
});
}
FAQs
Concise jQuery routing and navigation plugin based on nested navigation states.
The npm package jquery-atomic-nav receives a total of 0 weekly downloads. As such, jquery-atomic-nav popularity was classified as not popular.
We found that jquery-atomic-nav demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.