Unleash/unleash-proxy-client-js

feat: bootstrap

ivarconr opened this issue · 4 comments

Make it possible to bootstrap the SDK with feature toggle configuration.

Should have same format as returned from proxy:

[
  {
	"enabled": true,
	"name": "demoApp.step4",
	"variant": {
		"enabled": true,
		"name": "blue"
	}
  }
]

This is useful for multiple use-cases:

  • have sane defaults first time a user visit a webpage (empty localstorage)
  • easier local development and testing without dependency on unleash-proxy
  • serverside pre-render with sane defaults.

Scnerios:

  • If local cache is empty "boostrap" data should be the default
  • if there is locally cached feature toggle data we need an additional option to decide whether to use boostrap or cached configuration (boostrapOverride true).
  • Data retrieved from the proxy should always win.
  • Boostrap data is only valid until we have receive data from proxy. If the proxy does not return data we continue using boostrap or locally cached data.

Add two new optional constructor options:

  • boostrap - contains feature toggles (same format as from the proxy)
  • boostrapOverride - if true we will override any locally cached data.
PEZ commented

easier local development and testing without dependency on unleash-proxy

How do we initialise the proxy client without the proxy dependency? Just not give it an url?

How do we initialise the proxy client without the proxy dependency? Just not give it an url?

Exactly. As long as you do not call start() it will purely work on the boostrap data. You must provide an url, but can be anything as it will not be used.