Using Promises, Proxy, and async/await, oh my
This is a great start, but how can we really sweeten it up? Let’s start by changing
getLines to be getters.
OK, and what if we only cared about
Awesome, right? Well, awesome until you actually try to run that code and it doesn’t work. Can you spot the problem?
nvim.buffer returns a
Promise and we are attempting to access the
lines property of the
Promise, and not the resolved value of the promise. It would be the equivalent of this (using our first example with promises).
So what can we do? One option is to have
Neovim.getBuffer return a class with the interface of
Promise. Another option that comes to mind, is using a Proxy.
Is this something you would love to see more of, or am I just crazy? I would love to hear your thoughts.