Recently, I’ve noticed that web applications or extensions that interact with Wanikani’s API all use their own implementations of interaction. What this means is that any time someone wants to create a new web-based application, they need to either copy someone else’s code and finangle it to work with their own apps, or reinvent the wheel.
So, as a Typescript learning exercise to myself, and as a service to others, I have written a self-contained library that will handle all facets of interaction with the Wanikani API, include JSONP requests, caching, throttling, and more. The library has no external dependencies, except perhaps an ES6 Promise polyfill.
In order to use this library, one simply instantiates a WkApi object with the user’s API Key, and gets access to all types of API information.
I am open to suggestions or improvements. I am by no means an experienced library developer (all my time has been on discrete projects), and this is my first foray into writing open-source software.
I’m also on the Typescript-Angular-SPA learning train these days. I want to create an application that will help me pick apart tweets in Japanese, which will lean heavily on the Wanikani API for subscribers. This will help quite a bit!
I’m working on a framework with a similar concept (eliminating the reinvent-the-wheel), but for higher-level functionality, and mine is more of a shared-library, rather than static-linked. So, you load the framework as a standalone userscript, and client scripts can access its functionality via an interface object attached to ‘window.wkdata’. That way, you only have one instance of the framework, and is prevents duplicate API calls from different scripts (i.e. results from API calls are cached and shared among all scripts that ask for it).
Development is on hold for another week or so, though. We have an exchange student (Japan) that is returning home soon, and we want to spend as much time with her as we can before she leaves. After that, I’m gonna go hog-wild on script development
EDIT: Side question… how widely adopted is native Promise nowadays? I’m using jquery’s Deferred interface myself.
ecchash said...
This is awesome!!! How long did this take you to do? I'm a noob programmer so I have no concept of how long projects take =/. Sorry!
This was probably two days of spare-time dev, but I've been at this for many years. At first, it'll feel like you're beating on a brick wall, only sometimes making progress through it. But that's also the best way to learn--decide what you want to make, and just keep going until you have. Then remake it as you learn new techniques.