Better understand the client's destroy() method

Comments

1 comment

  • Dave Murphy

    This should be called when the website is closed. Where are you instantiating the SDK? The SDK initialization usually happens when you start the application since it requires some calls to our BE and some processing. Doing that several times would be a non-ideal usage. Destroying early the SDK could cause some problems, or the need to reinitialize it several times.  

    One reason to destroy the SDK is to avoid instantiating a second factory.  There should be no reason to do that.  Some users have done that in order to use a different key, say you want to pass a cookie as a key when the user is anonymous and a known user ID as a key after login.  You can do this by creating multiple clients in the same factory: https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-instantiate-multiple-sdk-clients

    0
    Comment actions Permalink

Please sign in to leave a comment.