New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

submission

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

submission

Observable interface for managing submission states

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

submission Build Status

Observable interface for managing submission submission states

Install

$ npm install --save submission

Usage

var Submission = require('submission')
var submission = Submission()

submission.pending()
//=> false

submission.error()
//=> null

Submission.submit(submission, function (callback) {
  //=> submission.pending() === true
  submit(callback)
})

function submit (callback) {
  //=> submit data to server
  //=> call callback w/ err, data
}

Submission.onData(submission, console.log)
//=> data

Submission.onError(submission, console.log)
//=> null / Error

API

Submission([data]) -> function

Returns an observable submission state.

data

Type: object Default: {pending: false, error: null}

The initial submission state.

Submission.submit(state, fn) -> undefined

state

Required
Type: function

A submission state observable.

fn

Required
Type: function
Arguments: callback

A function to call to trigger submission. The function will receive a callback that will update the submission state and trigger events based on the result.

Submission.onData(state, listener) -> function

Returns a function that removes the event listener.

state

Required
Type: function

A submission state observable.

listener

Required
Type: function

A function to be called with the submission data passed back from the function provided to Submission.submit.

Submission.onError(state, listener) -> function

Returns a function that removes the event listener.

state

Required
Type: function

A submission state observable.

listener

Required
Type: function

A function to be called with an error passed back from the function provided to Submission.submit.

License

MIT © Ben Drucker

Keywords

state

FAQs

Package last updated on 01 Jun 2016

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