Dumb DOM API questions

My solution was this:

function sendMessage() {
  window.safeMutableData.newMutation(auth)
    .then((mutationHandle) => {
      var date = new Date();
      var time = date.getTime();
      window.safeMutableDataMutation.insert(mutationHandle, time.toString(), textarea.value)
        .then(_ =>
          window.safeMutableData.applyEntriesMutation(mdHandle, mutationHandle))
        .then(_ => {
          Materialize.toast('Message has been sent to the network', 3000, 'rounded');
          window.safeMutableDataMutation.free(mutationHandle);
          getMutableDataHandle("getMessages");
        });
      textarea.value = "";

    });
}

example taken from Chaty. As far as I know nesting is the best way, but it should be possible to pass the handle as either a variable for chaining or a paramenter when doing a callback.

As far as I know you aren’t suppose to be able to remove the key from a Mutable Data Entry, Demoy’s Main.js video goes a bit into removing Mutable Data here and a few other functions of Mutable Data as well.

1 Like