{"id":19007520,"url":"https://github.com/helgee/optionaldata.jl","last_synced_at":"2026-04-23T00:30:20.945Z","repository":{"id":52430985,"uuid":"85695515","full_name":"helgee/OptionalData.jl","owner":"helgee","description":"Work with global data that might not be available","archived":false,"fork":false,"pushed_at":"2021-04-29T13:35:11.000Z","size":18,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T01:17:53.280Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helgee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-21T11:48:57.000Z","updated_at":"2023-03-17T12:07:49.000Z","dependencies_parsed_at":"2022-08-29T09:20:53.283Z","dependency_job_id":null,"html_url":"https://github.com/helgee/OptionalData.jl","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgee%2FOptionalData.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgee%2FOptionalData.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgee%2FOptionalData.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgee%2FOptionalData.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helgee","download_url":"https://codeload.github.com/helgee/OptionalData.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240035475,"owners_count":19737601,"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-11-08T18:38:39.046Z","updated_at":"2026-04-23T00:30:20.874Z","avatar_url":"https://github.com/helgee.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OptionalData\n\n*Work with global data that might not be available.*\n\n[![Build Status](https://github.com/helgee/OptionalData.jl/workflows/CI/badge.svg?branch=master)](https://github.com/helgee/OptionalData.jl/actions)\n[![Coverage](https://codecov.io/gh/helgee/OptionalData.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/helgee/OptionalData.jl)\n\nThis package provides the `@OptionalData` macro and the corresponding `OptData`\ntype which is a thin wrapper around a nullable value (of type `Union{T, Nothing} where T`).\nIt allows you to load and access globally available data at runtime in a type-stable way.\n\n## Installation\n\nThe package can be installed through Julia's package manager:\n\n```julia\nPkg.add(\"OptionalData\")\n```\n\n## Usage\n\n*OptionalData* has the following use cases:\n\n1. Parts of your package depend on data from the internet while other parts do not.\nIn the case of a network outage the package should offer a degraded experience but\nthe independent parts should still function.\n2. Your package requires manual initialisation steps, e.g. loading data from a\nuser-supplied file, and you do not want to repeat yourself writing code that\nchecks for the availability of the data.\n\nYou declare optional global data with the `@OptionalData` macro:\n\n```julia\nusing OptionalData\n\n# @OptionalData name type [error_msg]\n@OptionalData OPT_FLOAT Float64 \"Forgot to load it?\"\n\n# this expands to\nconst OPT_FLOAT = OptData{Float64}(string(:OPT_FLOAT), \"Forgot to load it?\")\n```\n\nYou access its value with `get` and check whether it is available with `isavailable`:\n\n```julia\n# This will throw a `NoDataError` because OPT_FLOAT does not contain a value, yet.\nget(OPT_FLOAT)\n# ERROR: OPT_FLOAT is not available. Forgot to load it?\nisavailable(OPT_FLOAT) == false\n```\n\nUse `push!` to load the data:\n\n```julia\npush!(OPT_FLOAT, 3.0)\nisavailable(OPT_FLOAT) == true\nget(OPT_FLOAT) == 3.0\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelgee%2Foptionaldata.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelgee%2Foptionaldata.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelgee%2Foptionaldata.jl/lists"}