Use dynamic interfaces

Requires: main module.

The basic recommended way to get most up-to-date settings in the presence of background updates is to use provider's Get method (see the relevant scenario) on each access attempt. However, it's also possible to obtain an inherently dynamic settings object whose properties are updated under the hood. This requires to use an interface as the settings model:

interface IMySettings
{
    string Option1 { get; }
    string Option2 { get; }
    ISubConfig Section { get; }
}

// Get once, use as a singleton:
var hotSettings = provider.CreateHot<IMySettings>(); 

// Properties of the 'hotSettings' object are mutable. 
// They will automatically return most up-to-date values.

Note that in order to get a guaranteed consistent view of the settings without "tearing" (observing a mix of values from before and after update due to a race condition) when using a nested object (section), it's recommended to access a snapshot of this nested object saved in a variable:

var section = hotSettings.Section;

// access a consistent view of 'section` properties

Last updated