{"id":48217504,"url":"https://github.com/ractive/pxt-interval","last_synced_at":"2026-04-04T19:01:02.064Z","repository":{"id":140855476,"uuid":"262134840","full_name":"ractive/pxt-interval","owner":"ractive","description":"Interval handlers that can be unusbscribed","archived":false,"fork":false,"pushed_at":"2020-09-01T16:23:58.000Z","size":514,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-12T00:21:37.875Z","etag":null,"topics":["makecode","makecode-arcade-extensions"],"latest_commit_sha":null,"homepage":"https://ractive.github.io/pxt-interval/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ractive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-05-07T19:00:06.000Z","updated_at":"2022-10-28T14:10:10.000Z","dependencies_parsed_at":"2023-05-04T22:24:38.903Z","dependency_job_id":null,"html_url":"https://github.com/ractive/pxt-interval","commit_stats":null,"previous_names":[],"tags_count":3,"template":null,"template_full_name":null,"purl":"pkg:github/ractive/pxt-interval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ractive%2Fpxt-interval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ractive%2Fpxt-interval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ractive%2Fpxt-interval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ractive%2Fpxt-interval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ractive","download_url":"https://codeload.github.com/ractive/pxt-interval/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ractive%2Fpxt-interval/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31409471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["makecode","makecode-arcade-extensions"],"created_at":"2026-04-04T19:00:46.708Z","updated_at":"2026-04-04T19:01:02.035Z","avatar_url":"https://github.com/ractive.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# pxt-interval ![Build Status Abzeichen](https://github.com/ractive/pxt-interval/workflows/MakeCode/badge.svg)\n\nIf you want to repeatedly do something in your game, you can add a callback method to `game.onUpdateInterval` like\n`game.onUpdateInterval(500, () =\u003e doSomething())`. But you cannot unsubscribe this callback from being executed - never.\n\nIf you want to do something periodically but only for a certain time, this extension can help you. A callback handler\nthat is registered to be executed in a given interval can also be unsubscribed again. The call to `Interval.on` returns\na function that can be called to do the unsubscription:\n\n```\nconst unsubscribe = Interval.on(500, () =\u003e doSomething());\n...\nunsubscribe();\n```\n\nHere an example how to fire projectiles every 500 milliseconds for 3 seconds:\n```\n// Shoot for 3 seconds\nconst unsubscribe = Interval.on(500, () =\u003e sprites.createProjectileFromSprite(myImage, mySprite, 50, 0));\nsetTimeout(() =\u003e unsubscribe(), 3000);\n```\n\nAnother example that lets a spaceship shoot until it's getting destroyed:\n```\nconst spaceShip = sprites.create(someSpaceshipImage);\nspaceShip.setFlag(SpriteFlag.AutoDestroy, true);\n\nconst unsubscribe = Interval.on(500, () =\u003e {\n    sprites.createProjectileFromSprite(img`\n    1\n    1\n    `, spaceShip, 0, -80);\n});\n\nspaceShip.vx = 30;\nspaceShip.onDestroyed(() =\u003e unsubscribe());\n```\n\n## Using it in your project\n\nTo use this extension in your project, choose \"Advanced \u003e Extensions...\" and enter `https://github.com/ractive/pxt-interval` in the search box.\n\nThis extension uses the [pxt-heap](https://github.com/jwunderl/pxt-heap) extension to easily fetch the next callback handler that should be executed.\n\n#### Metadata\n\n* for PXT/arcade\n\u003cscript src=\"https://makecode.com/gh-pages-embed.js\"\u003e\u003c/script\u003e\u003cscript\u003emakeCodeRender(\"{{ site.makecode.home_url }}\", \"{{ site.github.owner_name }}/{{ site.github.repository_name }}\");\u003c/script\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fractive%2Fpxt-interval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fractive%2Fpxt-interval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fractive%2Fpxt-interval/lists"}