Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

Latest commit

 

History

History
28 lines (22 loc) · 889 Bytes

README.md

File metadata and controls

28 lines (22 loc) · 889 Bytes

netox

depends on clay-request which depends on whatwg-fetch polyfill

Netox = require 'netox'
netox = new Netox
  headers: {} # optional, lower-cased key-value defaults for server-side calls

# same signature as whatwg-fetch, returns an RxJS observable of clay-request response
netox.stream 'http://x.com/x'
.subscribe (res) -> ...

# same signature as whatwg-fetch, re-fetches streams, returns clay-request response
netox.fetch 'http://x.com/x', {method: 'POST'}
netox.fetch 'http://x.com/x', {isIdempotent: true} # dont re-fetch streams
.then (res) -> ...

# put this in a server-side generated script tag
netox.getSerializationStream()
.map (serialization) ->
  # window['NETOX'] = {...};

# send analytics events with timing info
netox.stream 'http://x.com/x', {isTimed: true}
netox.onTiming ({url, elapsed}) ->
  # hyperplane.emit 'timing', {fields: {url, value: elapsed}}