Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid color_disabled global state #4

Open
seaneagan opened this issue Dec 18, 2014 · 3 comments
Open

Avoid color_disabled global state #4

seaneagan opened this issue Dec 18, 2014 · 3 comments

Comments

@seaneagan
Copy link

color_disabled is global state, and since ansi color is kind of a cross-cutting concern, two different parts of an application could easily mess up each other's state. I think the best way to handle this would be to provide a means to run code in a Zone which exposes a Zone local colorDisabled value, which each ansi pen can read from.

I have a mechanism for this in the clock package:

https://github.com/seaneagan/clock/blob/master/lib/src/zoned_value.dart

Which I use for the withClock method seen here:

https://github.com/seaneagan/clock

@seaneagan
Copy link
Author

See here for some background: chalk/chalk#46

@jtmcdole
Copy link
Member

This package has used a global for a while. I wonder if I could store an Expando on a zone and retrieve it (since Zone.currrent[#color] cannot be set).

@jtmcdole jtmcdole reopened this Sep 27, 2020
@jtmcdole
Copy link
Member

I can add a Expando on Zone.current, which makes things much nicer. I'll keep color_disabled for backwards compatibility though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants