From ee310f857362134aed78cf7ceb66c092ca40e72f Mon Sep 17 00:00:00 2001 From: Donald Chickeme Date: Wed, 28 Feb 2024 13:05:21 +0100 Subject: [PATCH] Update ReadMe with details of FormattedDeferredText (#99) * update readme with details of FormattedDeferredText * adjust FormattedDeferredText description --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index c33392c..c918404 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,19 @@ val deferredFormattedString: DeferredFormattedString = deferredFormattedPlurals. // If you have only the format args: val deferredPlurals: DeferredPlurals = deferredFormattedPlurals.withFormatArgs("million") ``` +#### Auxiliary type(s) +`FormattedDeferredText` is a type that wraps a `DeferredFormattedString` and it's relevant +arguments. This is useful when the format arguments are determined at the declaration site rather +than the resolution site. + +```kotlin +val formattedString = DeferredFormattedString.Constant("%s and %s") +// Formatted text with arguments at resolution site +formattedString.resolve(context, "A", "B") + +// Formatted text with arguments at declaration site +FormattedDeferredText(formattedString, "A", "B").resolve(context) +``` All text-related types can eventually be converted to `DeferredText` through similar extensions.