nic-dgl104-winter-2024 / pattern-library

A multi-language library containing implementations of common software design and architecture patterns
4 stars 37 forks source link

Observer pattern live demo #99

Open Dhuds1 opened 6 months ago

Dhuds1 commented 6 months ago

I wanted to create an observer pattern live demo to showcase how the observer pattern functions and can be used. As of this moment it is not completed but I wanted to share it to hopefully get some feedback!

There are two primary reasons I started this project, the first is I has a hard time understanding this pattern and its use cases, and the second reason is I wanted write some JS, which is something I haven't used in a while.

I didn't use any sources, or other materials to create this, but I did use chat GPT as a documentation of sorts, since its been a while since I've used JS I've forgotten things like adding to an array, mutating an array etc. and I was too lazy to search every question on google.

As of right now, the only things that are functional on the GUI / website version are adding Observer and Subject objects, it will also save them into your local host.

I'm still needing to add Subscribing, Unsubscribing, Data setting, updating and setting the delay functionality.

The delay functionality is really how this comes together, as it will complete one of the steps setting data, updating observer, asking subject for the new data, displaying new data

Most things will work in the backed, like subscribing and unsubscribing, data setting, data getting, updating etc. but not on the front end, having a user mutate and change the data themselves, which was the purpose of this file.

I will say this warning

DO NOT LOOK AT PRINT.JS IF YOU VALUE YOUR SANITY

I still do not understand why I've created such a monstrosity of a file

ash-teach commented 5 months ago

Oof. This is a lot of work! I've taken a scan through, and I see what you're up to - it's a good idea! - though I haven't dived deep into it for a full assessment.

I'll leave this one open in case you ever decide to come back to it, or in case anyone stumbles across and would like to provide some feedback at some point.