gwnalog 1: mae hi'n rhestru!
a dw i'n defnyddio hi'n barod
hwyl: balchmeddalweddgwnadallogas mentioned on my sole active social media, i've started a new project: todo. i don't expect this to be particularly useful for anyone but me, but i do expect it to be quite handy for that target audience.
i'm not going to go into what, specifically, irritates me about existing options. it's different for each of them, for one thing, and a lot of it just comes down to: i know exactly what i want and i can build it. so fuck it, let's do that.
i'm quite proud that i built the first version in two afternoons, and already with quite nice styles. not ideal, but i'm prioritizing readability on my phone over everything else. the downside is that in my haste, i made two bad choices:
- using IndexedDB. it certainly has its place! that place is not in a tiny todo-list app. a tremendous amount of the code is just wrangling that, especially since i prefer promises/
async
to callback-oriented programming. - writing absolutely awful, intertwined code. mostly because i was rushing, partly because i'm not too familiar with javascript, and a little bit because i don't want to engage with javascript's mockery of object-oriented code.
i've spent a lot of today fixing those issues. first, i switched IndexedDB for localStorage. it's not "better", per se, but it's way simpler, so it fits way better here.
the second is more complex to tackle, obviously. my current approach is one i've used occasionally to structure javascript:
let module = {
shared: /* ... */,
func1: function(arg) { /* ... */ },
func2: function(arg) { /* ... */ },
};
// called as:
module.func1(whatever);
notably, this isn't a class; you can't instantiate a module
. it's just a bundle of related code. thanks to how function
works, this
will refer to the module. it's not too different to just a bunch of free functions and global constants, but it adds just enough encapsulation to force me to think about interfaces and data models.
but honestly, the resulting code isn't fantastic either. what's most important is that it's a lot more neatly divided, so it should be pretty clean to (e.g.) add in some http requests to save/load from a server.
eventually, i should figure out how modern javascript is actually best written. eventually. not today, though. mustn't let myself become a webdev. (/joke)
anyway, if you want to try it, feel free. if you find a bug, let me know, but if you want new features – the code's pretty simple! you should dive into it and make your own version. that's not just me avoiding the extra work, genuinely, i think more people should make websites for fun.
if you do base yours off mine, i'd love to hear about it. hell, even if you just rehost it i'd be delighted.
anyway, you'll notice this is "todolog 1". i do intend to keep working on this! eventually i want it to have:
- the implied backend server for (encrypted) storage
- reocurring tasks: when you mark one instance done another spawns
- "failed" tasks: because tracking what you didn't do is important too
- offline functionality (via service workers/as a pwa)
- push notifications for tasks due today
we'll see how quick i get any of this done, tbh. most of my goal is already accomplished, with a functioning todo list i can write my todos into. from here it's just improving things until it stops being worth it.