Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Is there a way to refresh singletons that are registered with the RegisterFor attribute? I have plugin settings I would like to avoid looking up on every request, so I'm registering a few helper classes as Singletons. This works whell because they load their settings from the DB when first constructed. However, I need to be able to refresh them if the store owner updates the plugin settings.
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
You can create a public void function in your singleton class that will reload the data from the database and call this function when the plugin settings are saved.
Hope this helps!
|
1 user thanked shaharyar for this useful post.
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Thank you, this is indeed what I ended up doing. Created an IReloadable interface and am using it for all my Singleton helper classes so I can refresh whenever settings are saved.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close