{"id":16865570,"url":"https://github.com/erikras/callbag-pausable","last_synced_at":"2025-04-11T09:50:16.581Z","repository":{"id":57193111,"uuid":"132140783","full_name":"erikras/callbag-pausable","owner":"erikras","description":"⏯️ Callbag Pausable is a callbag that will convert any callbag stream into one that can be paused and resumed via data or talkback events.","archived":false,"fork":false,"pushed_at":"2019-12-10T17:14:15.000Z","size":208,"stargazers_count":10,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T06:41:41.717Z","etag":null,"topics":["callbag","observable","pausable","pause","reactive","resume","rxjs","streams"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erikras.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-04T13:01:20.000Z","updated_at":"2023-06-04T05:04:34.000Z","dependencies_parsed_at":"2022-09-01T06:00:10.807Z","dependency_job_id":null,"html_url":"https://github.com/erikras/callbag-pausable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fcallbag-pausable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fcallbag-pausable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fcallbag-pausable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fcallbag-pausable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erikras","download_url":"https://codeload.github.com/erikras/callbag-pausable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248370550,"owners_count":21092827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["callbag","observable","pausable","pause","reactive","resume","rxjs","streams"],"created_at":"2024-10-13T14:47:36.605Z","updated_at":"2025-04-11T09:50:16.565Z","avatar_url":"https://github.com/erikras.png","language":"JavaScript","readme":"# ⏯️ callbag-pausable\n\n[![NPM Version](https://img.shields.io/npm/v/callbag-pausable.svg?style=flat)](https://www.npmjs.com/package/callbag-pausable)\n[![NPM Downloads](https://img.shields.io/npm/dm/callbag-pausable.svg?style=flat)](https://npm-stat.com/charts.html?package=callbag-pausable)\n[![Build Status](https://travis-ci.org/erikras/callbag-pausable.svg?branch=master)](https://travis-ci.org/erikras/callbag-pausable)\n[![codecov.io](https://codecov.io/gh/erikras/callbag-pausable/branch/master/graph/badge.svg)](https://codecov.io/gh/erikras/callbag-pausable)\n\n\u003cimg src=\"valve.jpg\" align=\"right\"/\u003e\n\n[Callbag](https://github.com/callbag/callbag) operator that allows data and talkbacks to pass through it freely until it receives a data or talkback message of `PAUSE`, in which case it stops the downflow of data until it receives another data or talkback message of `RESUME`.\n\nThink of it like a valve on a pipe.\n\n## Usage\n\n\u003c!-- prettier-ignore --\u003e\n```js\nimport interval from 'callbag-interval'\nimport observe from 'callbag-observe'\nimport pipe from 'callbag-pipe'\nimport pausable, { PAUSE, RESUME } from 'callbag-pausable'\n\nconst source = pipe(interval(100), pausable)\n\nsetTimeout(() =\u003e {\n  console.log('PAUSING')\n  source(1, PAUSE)\n}, 400)\nsetTimeout(() =\u003e {\n  console.log('RESUMING')\n  source(1, RESUME)\n}, 1000)\n\nobserve(console.log)(source) // 0\n                             // 1\n                             // 2\n                             // PAUSING\n                             // RESUMING\n                             // 9\n                             // 10\n                             // 11\n                             // ...\n```\n\n\u003c!-- prettier-ignore-end --\u003e\n\nOr, as a talkback to an existing callbag (assuming `callbag$` has `pausable` somewhere in its pipe):\n\n\u003c!-- prettier-ignore --\u003e\n```js\nconst sendTalkbackValue = (callbag$, value) =\u003e {\n  callbag$(0, (type, talkback) =\u003e {\n    if (type === 0) {\n      talkback(1, value) // send value\n      talkback(2)        // terminate\n    }\n  })\n}\nconst pause = callbag$ =\u003e sendTalkbackValue(callbag$, PAUSE)\nconst resume = callbag$ =\u003e sendTalkbackValue(callbag$, RESUME)\n```\n\n\u003c!-- prettier-ignore-end --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikras%2Fcallbag-pausable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferikras%2Fcallbag-pausable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikras%2Fcallbag-pausable/lists"}