GithubHelp home page GithubHelp logo

Comments (3)

apucacao avatar apucacao commented on July 29, 2024 1

Hi @mickeyreiss-visor ,

We recommend combining the Node.js SDK with the client-side SDK for server-side rendering.

From a high-level โ€” assuming you use express.js or something similar โ€” it looks like this:

  1. initialize the Node SDK as part of your server app
  2. when a request comes in, grab the flag settings for the current user and pass those values to the server-side rendering code
  3. bootstrap the client-side SDK with the flag values for the current user

Bootstrapping the client-side SDK this way has two benefits:

  • you can render the UI on the server with the correct flag values for the current user
  • it causes SDK initialization to be practically instantaneous

Hope that helps. Let me know if you have any other questions ๐Ÿ˜ƒ

from js-client-sdk.

Askadias avatar Askadias commented on July 29, 2024

Hi @apucacao, having the following error on server client initialization in case of React Server-Side Rendering:
TypeError: Cannot read property 'removeIf' of undefined

image

Probably because of a custom function being added to Array prototype. But still seems like for in is not the best option here while modifying Array.prototype is no the best option to define a function.

Array.prototype.removeIf = function (callback) {
  let i = this.length;
  while (i--) {
    if (callback(this[i])) {
      this.splice(i, 1);
    }
  }
};

from js-client-sdk.

eli-darkly avatar eli-darkly commented on July 29, 2024

@Askadias Thank you for reporting this, but in the future could you please file a new issue rather than commenting on a closed one that's more than two years old? Also, I think you've filed it in the wrong repositoryโ€” the code you've screenshotted is not part of js-client-sdk; it appears to be part of the server-side Node SDK, specifically its logic for evaluating feature flag rules, which is not something js-client-sdk does at all.

from js-client-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.