From 0b3796f85614ad84e117199028ec6b11b5fa6144 Mon Sep 17 00:00:00 2001 From: Ron Cohen <744+roncohen@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:22:06 +0000 Subject: [PATCH] docs: simplify flag reads and clarify client lifecycle --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ff27c6..2315233 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,18 @@ from reflag import Client with Client() as client: flags = client.bind({"user": {"id": "user-123"}, "company": {"id": "company-123"}}) - enabled = flags.get_flag("my-flag", default=False) + enabled = flags.get_flag("my-flag") settings = flags.get_flag("settings", default={"theme": "light"}) ``` -Replace the flag keys and IDs with your own. Reuse one client per application worker; -initialization loads definitions, and subsequent flag reads are local and in-memory. +Omitting `default` is equivalent to `default=False` and returns a `bool`. + +Replace the flag keys and IDs with your own. + +Create and initialize **one client per application worker** at startup, reuse it +across requests, and close it at shutdown. Do not create a new client for each request +or flag check. Use `client.bind(...)` for request-specific user/company context. +Initialization loads definitions; subsequent flag reads are local and in-memory. For async applications, use `async with AsyncClient()` in the application lifespan. Flag reads remain synchronous: do **not** await `get_flag()`.