logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
sweeperqb  
#1 Posted : Monday, May 17, 2021 3:21:27 PM(UTC)
sweeperqb

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.

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shaharyar  
#2 Posted : Tuesday, May 18, 2021 2:21:41 AM(UTC)
shaharyar

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!
thanks 1 user thanked shaharyar for this useful post.
sweeperqb on 5/19/2021(UTC)
sweeperqb  
#3 Posted : Wednesday, May 19, 2021 8:33:24 AM(UTC)
sweeperqb

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.
Users browsing this topic
Guest
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.