Ejemplo n.º 1
0
 * We store current slide number in location.hash.
 */
const slide = History.location.derive(location =>
  parseInt(location.hash.slice(1), 10) || 1);

/**
 * We store current mode in persistent atom (syncs with localStorage).
 */
const mode = Persistence.atom('__react_shower_mode__', 'list');

/**
 * App state is a {slide, mode}
 *
 * We expose struct derivation to prevent direct modification of the state.
 */
export const state = Derivable.struct({mode, slide});

/**
 * Change currently active slide.
 */
export function changeActiveSlide(nextSlide) {
  const hash = '#' + nextSlide;
  // XXX: Because browser bugs with :target we must do this instead of fancy
  // History.location.swap(...) :(
  window.location.hash = hash;
}

/**
 * Change mode.
 */
export function changeMode(nextMode) {
Ejemplo n.º 2
0
 setDependencies(dependencies) {
   this._parent = struct(dependencies);
   this.dependencies = dependencies;
 }