yazz.com
yazz.com

Reputation: 58826

Can I extend ClojureQL using protocols or multimethods?

I would like to add an "add-watch" method to the clojureql tables. Is it possible to just use a multimethod to do this?

Upvotes: 2

Views: 164

Answers (1)

Lau Jensen
Lau Jensen

Reputation: 214

You have to think about how you want this to work first. If a change happens to the SQL table, how will you detect it? The SQL database doesn't call you informing you of the change, so either you have to poll at an interval or you have to track the function in CQL which can update a table, ie. conj!, disj!, update-in!.

If you opt for monitoring those functions, you will currently have to modify the source and add a call to those 3 functions which alerts your watcher - It can simple be a function, no need to multimethods or protocols.

Think hard about when/where this is useful and how you as a user would best be served by CQL. Then if you come up with something brilliant, make an issue on Github and let us know about.

Thanks, Lau

Upvotes: 2

Related Questions