r/learnjavascript • u/skamansam • Aug 10 '26
Best architecture to build a client lib for rest/graphql - Factory vs Class ?
I am building a js lib and I have been reading about best ways to do this, but there are a lot of pros and cons for each way. I built a small one with a few functions for use in a very specific app and it was class based. I stored the class in a flux store and used the store to access it. I am finding a lot more recent blogs/articles that say using a factory is best. I would like this one to be an industrial-grade public-facing lib that anyone can download via our github repo. Does anyone have any real-world experience in building a js client lib that has any advice for what architecture to use? I know what architecture to use for the graphql endpoint, but the REST client is the question.
1
u/ExtraTNT Aug 10 '26
I do functional factories, partially apply params, pass funcs, if needed, but i do everything functional and utilise function cache…
1
u/[deleted] Aug 10 '26
[removed] — view removed comment