{"id":16401507,"url":"https://github.com/plugfox/isolation","last_synced_at":"2025-07-25T14:13:34.255Z","repository":{"id":57679419,"uuid":"522294869","full_name":"PlugFox/isolation","owner":"PlugFox","description":"Isolate helper for flutter and dart.","archived":false,"fork":false,"pushed_at":"2022-10-27T06:47:23.000Z","size":34,"stargazers_count":15,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T18:06:07.229Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","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/PlugFox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-07T18:37:38.000Z","updated_at":"2024-06-27T04:36:46.000Z","dependencies_parsed_at":"2022-08-24T19:30:22.981Z","dependency_job_id":null,"html_url":"https://github.com/PlugFox/isolation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fisolation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fisolation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fisolation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fisolation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlugFox","download_url":"https://codeload.github.com/PlugFox/isolation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245061382,"owners_count":20554563,"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":[],"created_at":"2024-10-11T05:43:19.426Z","updated_at":"2025-03-23T05:31:10.221Z","avatar_url":"https://github.com/PlugFox.png","language":"Dart","readme":"# Isolation\n\n[![platform_info](https://img.shields.io/pub/v/isolation.svg)](https://pub.dev/packages/isolation)\n[![Actions Status](https://github.com/PlugFox/isolation/actions/workflows/checkout.yml/badge.svg)](https://github.com/PlugFox/isolation/actions/workflows/checkout.yml)\n[![Coverage](https://codecov.io/gh/PlugFox/isolation/branch/master/graph/badge.svg)](https://codecov.io/gh/PlugFox/isolation)\n[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)\n[![Linter](https://img.shields.io/badge/style-linter-40c4ff.svg)](https://dart-lang.github.io/linter/lints/)\n\n---\n\n# Overview\n\nThe package simplifies the creation and interaction between isolates.\nIt encapsulates the entire boilerplate, leaving the developer with only transport with an API that looks like two stream controllers.\n\nThe package also helps to preserve typing and pass exceptions between isolates.\n\n# Usage\n\n## JSON parser\n\n```dart\nimport 'dart:async';\nimport 'dart:convert' show jsonDecode;\n\nimport 'package:isolation/isolation.dart';\n\ntypedef JsonMap = Map\u003cString, Object?\u003e;\n\n/// Main isolate\nvoid main() =\u003e Future\u003cvoid\u003e(() async {\n      // Create a new isolate controller\n      final controller = IsolateController\u003cString, JsonMap\u003e(\n        _parser,    // Isolate function\n        lazy: true, // The isolate will not be created until the first message\n      )\n       // Add few messages to the isolate:\n       ..add('{}')\n       ..add('{\"field\": 123}')\n       ..add('{\"fizz\": \"buzz\", \"value\": 2, \"undefined\": null}');\n      // Listen messages from slave isolate\n      await controller.stream.take(3).forEach(print);\n      // Gracefully closing connection and finally kill slave isolate\n      await controller.close(force: false);\n    });\n\n/// Slave isolate for parsing JSON, where you can subscribe to the stream\n/// from the main isolate and send the result back through the controller.\nFuture\u003cvoid\u003e _parser(IsolateController\u003cJsonMap, String\u003e controller) =\u003e\n    controller.stream.forEach((json) {\n      final result = jsonDecode(json) as Object?;\n      (result is JsonMap)\n          ? controller.add(result)\n          : controller.addError(const FormatException('Invalid JSON'));\n    });\n```\n\n## Installation\n\nAdd the following to your `pubspec.yaml` file to be able to do code generation:\n\n```yaml\ndependencies:\n  isolation: any\n```\n\nThen run:\n\n```shell\ndart pub get\n```\n\nor\n\n```shell\nflutter pub get\n```\n\n## Coverage\n\n[![](https://codecov.io/gh/PlugFox/isolation/branch/master/graphs/sunburst.svg)](https://codecov.io/gh/PlugFox/isolation/branch/master)\n\n## Changelog\n\nRefer to the [Changelog](https://github.com/plugfox/isolation/blob/master/CHANGELOG.md) to get all release notes.\n\n## Maintainers\n\n[Plague Fox](https://plugfox.dev)\n\n## License\n\n[MIT](https://github.com/plugfox/isolation/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugfox%2Fisolation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplugfox%2Fisolation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugfox%2Fisolation/lists"}