Q:

How to create an observableArray "before push" subscription?

I'm trying to track down why I'm getting duplicate entries in an observableArray. Is there a way to subscribe to see before an item is added to an observable array?  I can see after an item is added by using a subscription like:
var myArr = ko.observablearray();
myArr.subscribe(function (changes) {
    changes.forEach(function (change) {
        var item = change.value;
        var itemStatus = change.status;
        if (itemStatus === "added") {

        } else if (itemStatus === "deleted") {

        }
    });
}, null, "arrayChange");

A:

TL;DR: You can use the signature myArray.subscribe(func, null, "beforeChange").

An observableArray is just an observable with extra properties, so all subscribe features work normally. From the relevant docs:

The subscribe function accepts three parameters: callback is the function that is called whenever the notification happens, target (optional) defines the value of this in the callback function, and event (optional; default is "change") is the name of the event to receive notification for.
...
If you want to be notified of the value of an observable before it is about to be changed, you can subscribe to the beforeChange event. 

Here's an example:

var ViewModel = function() {
  var self = this, i = 1;
  
  self.items = ko.observableArray([i++, i++, i++]);  
  
  self.addItem = function() { self.items.push(i++); };
  
  self.items.subscribe(function(oldValue) {
    alert("Changed from: " + ko.toJSON(oldValue));
  }, null, "beforeChange");
  
  self.items.subscribe(function(newValue) {
    alert("Changed to this new value: " + ko.toJSON(newValue));
  });
};

ko.applyBindings(new ViewModel());
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<button data-bind="click: addItem">Add Item</button>
<ul data-bind="foreach: items"><li data-bind="text: $data"></li></ul>

