1.0.6 • Published 8 years ago

inflight v1.0.6

Weekly downloads
21,200,968
License
ISC
Repository
github
Last release
8 years ago

inflight

Add callbacks to requests in flight to avoid async duplication

USAGE

var inflight = require('inflight')

// some request that does some stuff
function req(key, callback) {
  // key is any random string.  like a url or filename or whatever.
  //
  // will return either a falsey value, indicating that the
  // request for this key is already in flight, or a new callback
  // which when called will call all callbacks passed to inflightk
  // with the same key
  callback = inflight(key, callback)

  // If we got a falsey value back, then there's already a req going
  if (!callback) return

  // this is where you'd fetch the url or whatever
  // callback is also once()-ified, so it can safely be assigned
  // to multiple events etc.  First call wins.
  setTimeout(function() {
    callback(null, key)
  }, 100)
}

// only assigns a single setTimeout
// when it dings, all cbs get called
req('foo', cb1)
req('foo', cb2)
req('foo', cb3)
req('foo', cb4)
cuc-gaf@huyhpham/rn-linearchetype-librarycomponennentteasy-select-rnchinjowwchinjowvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imagepipihomern-send-smsspecify-importsbabel-specify-imports@icanpm/api-mastergew-nodejs-api-client@arisageha/react-lazyload@arisageha/react-lazyload-fix@oneplanetcrowd/developers@cashremit/cr-streamline-icons@almeidaa/msreact-native-template-rfbaseairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxf@phil8795/pecuniarius-apikubii-apideneme323112@steven-torres/jsxr@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjames@sonammalhotra/lotide@smishra17/lotide@cheapthrills/lotidereact-native-covid-sdkgql_din_modnoresca-tools-dev444bitgetafryxiconsreact-native-thanh-toast-librarymutasi-bca@jttechnic/interpreter@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewer@eginnovations/eginnovations-capacitor-plugin@cujo-common/simple-hello-world-example@saeon/ol-react@saeon/quick-formauto-extractcthpb-plugin-social@iobroker-community-adapters/iobroker.device-watcher@olivervorasai/slidermysql-formatpanqibaoreact-native-printer-brothersrn-pdf-reader-offlinesendautomessengermessagecbmis-ai-toolbox@belko.tech/belko-multi-wallet-sdkmercury-uni@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-testasterjscogoportutilsukor-remasteruncoded-connect@reversodev/oceanic-fleetlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29levinodelibuinz-notification@nicholasjj/lotidetemp-mail-fucktalent-to-vite-cliwilscanner@khalitovadel/abstract-repository@oiti/documentoscopy-react-nativejs4cytoscape@respondea/cordova-plugin-v-inappbrowser@mink-opn/build-tokensquoc-testreact-native-slider-kfnodejs-fileshareunblock-block-save-variables@infinitebrahmanuniverse/nolb-infl@prodam/prodam-typescclibyarntest@saaspe/components
1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago