Skip to content

Instantly share code, notes, and snippets.

@camshaft
Created October 29, 2012 04:37
Show Gist options
  • Save camshaft/3971543 to your computer and use it in GitHub Desktop.
Save camshaft/3971543 to your computer and use it in GitHub Desktop.
%% Create the state
State1 = ot_text:create(),
%% Make an op. Let's say the request wanted to add "foo" at position 0
Op1 = #ot_text_r{i="foo",p=0},
%% Apply the operation
State2 = ot_text:apply(State1, [Op1]),
%% State2 now equals "foo"
%% We can also delete some text
Op2 = #ot_text_r{d=<<"o">>,p=1},
%% Apply the delete operation
State3 = ot_text:apply(State2, [Op2]).
%% State3 now equals "fo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment