npm.io
0.1.1 • Published 7 years ago

simurl

Licence
MIT
Version
0.1.1
Deps
0
Size
3 kB
Vulns
0
Weekly
0

simurl

Simurl (simulate URL) is a JavaScript library that allows you to create variables that update and listen to the url.

Usage

import { SimUrl } from 'simurl';

const state = new SimUrl;

state.addProperty('name', 'Joe'); // Creates a state variable 'name' and sets the default value to 'Joe'. If a URL path is already present in this location (in this case, the first location), then that value will be used.
// The url will update, for example www.example.com/Joe

// If the URL was www.example.com/John, the value would be John.

console.log(`Hello, ${state.name}!`); // Hello, Joe!

state.name = 'John';
// The url is now www.example.com/John

console.log(state.name); // John

history.back();
console.log(state.name); // Joe