You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@hyperapp/logger

Package Overview
Dependencies
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperapp/logger

Log Hyperapp state updates and action information to the console

0.5.0
latest
Source
npmnpm
Version published
Weekly downloads
212
11.58%
Maintainers
7
Weekly downloads
 
Created
Source

<img height=24 src=https://cdn.rawgit.com/jorgebucaran/f53d2c00bafcf36e84ffd862f0dc2950/raw/882f20c970ff7d61aa04d44b92fc3530fa758bc0/Hyperapp.svg> Hyperapp Logger

Travis CI Codecov npm Slack

A Hyperapp higher-order app that logs state updates and action information to the console.

Getting Started

This example shows a counter that can be incremented or decremented. Go ahead and try it online with your browser console open to see the log messages.

import { h, app } from "hyperapp"
import { withLogger } from "@hyperapp/logger"

const state = {
  count: 0
}

const actions = {
  down: () => state => ({ count: state.count - 1 }),
  up: () => state => ({ count: state.count + 1 })
}

const view = (state, actions) => (
  <main>
    <h1>{state.count}</h1>
    <button onclick={actions.down} disabled={state.count <= 0}></button>
    <button onclick={actions.up}></button>
  </main>
)

withLogger(app)(state, actions, view, document.body)

Screenshot

Installation

Node.js

Install with npm / Yarn.

npm i @hyperapp/logger

Then with a module bundler like rollup or webpack use as you would anything else.

import { withLogger } from "@hyperapp/logger"

Browser

Download the minified library from the CDN.

<script src="https://unpkg.com/@hyperapp/logger"></script>

You can find the library in window.hyperappLogger.

const { withLogger } = hyperappLogger

Usage

Compose the withLogger function with your app before calling it with the usual arguments.

import { withLogger } from "@hyperapp/logger"

withLogger(app)(state, actions, view, document.body)

// Or if you need to pass options
withLogger(options)(app)(state, actions, view, document.body)

Options

options.log

Use it to customize the log function.

withLogger({
  log(prevState, action, nextState) {
    // format and send your log messages anywhere you like
  }
})(app)(state, actions, view, document.body)

License

Hyperapp Logger is MIT licensed. See LICENSE.

FAQs

Package last updated on 05 Mar 2018

Did you know?

Socket

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.

Install

Related posts