public class

OptimizelyCodeBlocks

extends Object
java.lang.Object
   ↳ com.optimizely.CodeBlocks.OptimizelyCodeBlocks

Class Overview

OptimizelyCodeBlocks is the singleton class which handles all the functionality required for implementing CodeBocks. In Editor mode, it interacts with socket server to communicate existing code blocks and update them for the app. Optimizely will *only* interact with the socket server if the editor module is included. The module is included by default with the Optimizely "bundle" which you are probably using.

Summary

Nested Classes
class OptimizelyCodeBlocks.OptimizelyCodeBlockBuilder  
Public Constructors
OptimizelyCodeBlocks(Optimizely optimizely)
Public Methods
OptimizelyCodeBlocks.OptimizelyCodeBlockBuilder blockBuilder(String codeBlockKey)
Method to create a OptimizelyCodeBlockBuilder in client app with name which can be used to create a code block
OptimizelyCodeBlock makeCodeBlock(String codeBlockKey, OptimizelyCodeBlock.Callback callback, String... branchNames)
Method to create a OptimizelyCodeBlock in client app with name and default code block.
OptimizelyCodeBlock makeCodeBlock(String codeBlockKey, String... branchNames)
Method to create a OptimizelyCodeBlock in client app with name and default code block.
void resetCodeBlocks()
Resets all forced code blocks in EDIT mode.
void sendCodeBlocks()
Sends all the registered code blocks to editor through socket server in a batches.
void setEditorModule(EditorModule editor)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public OptimizelyCodeBlocks (Optimizely optimizely)

Public Methods

public OptimizelyCodeBlocks.OptimizelyCodeBlockBuilder blockBuilder (String codeBlockKey)

Method to create a OptimizelyCodeBlockBuilder in client app with name which can be used to create a code block

Parameters
codeBlockKey name of the code block.
Returns
  • new code block builder

public OptimizelyCodeBlock makeCodeBlock (String codeBlockKey, OptimizelyCodeBlock.Callback callback, String... branchNames)

Method to create a OptimizelyCodeBlock in client app with name and default code block. If a callback is provided it will be called when the active branch is changed in EDIT mode.

Parameters
codeBlockKey name of the code block.
callback an instance OptimizelyCodeBlock.Callback
branchNames the names of the branches
Returns
  • new code block

public OptimizelyCodeBlock makeCodeBlock (String codeBlockKey, String... branchNames)

Method to create a OptimizelyCodeBlock in client app with name and default code block.

Parameters
codeBlockKey name of the code block.
branchNames the names of the branches
Returns
  • new code block

public void resetCodeBlocks ()

Resets all forced code blocks in EDIT mode.

public void sendCodeBlocks ()

Sends all the registered code blocks to editor through socket server in a batches. Should be invoked just after Optimizely is initialized.

public void setEditorModule (EditorModule editor)