0.1.1 • Published 5 years ago

simurl v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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