@gdeer81 I have a few guesses as to why that might be. define
is not very development friendly at the moment. So using rules instead will help. We decided to use define
to showcase the logic, but the app was developed primarily using rules. The reason rule
is more dev friendly than define
basically comes down to how define
‘s name is based upon its consequence, so redefining the consequence produces a new rule and maintains the old one. I’ve been working to fix this along with hot reloading in general. I have it working in Clojure but Clojurescript is a little tricker so it’s taking a bit longer
This same thing will occur if you rename a rule or delete it from the file. The fix I am working on will rectify this as well. The cause is similar, but you can get around it (somewhat laboriously) by using ns-unmap on the rule you renamed/removed, or by restarting figwheel. Changes to conditions or consequences of rules should work fine, however. In development I found myself adding comments to rules when I wanted to rename them and then renaming them later so I didn’t have to deal with this
If you have time to let me know more about the problem you ran into I may be able to provide a more helpful answer
@alex-dixon my filtering might be too aggressive https://gist.github.com/gdeer81/b9d69b8c6915cd7f9199a9fa3359e145
oddly enough it was working at one time and then I was trying to do some id truncating for the product description and got an error since you can't treat a uuid like a seq and take 5. but that caused the breakage and even after I backed out the change it still wouldn't show any products. I might need to put some better logging in there
Yeah heh was just going to mention that as well as a downfall of defines, as they don’t support logging. Forgot to mention that as another reason I typically don’t use them in development right now until I have something nailed down, as my primary method of debugging with where our tooling is at is println
I think I’d probably converting to rules and add printlns. There might be a problem related to mutual exclusivity and insert-logical. As of the latest version I think we’re surfacing an error in this case
I might also write a rule that just prints visible product ids
Not saying you should just letting you know what I might do faced with the same problem
I’m wondering whether it might be a problem with mutual exclusivity given the introduction of the new category filter. Just noticing the second rule doesn’t have anything to say about the category filter
@gdeer81 I’m assuming you’re testing with no facts about the filters in the session?
(in which case all products should be visible instead of none of them)
I extended the filter-option-data map to have a category key that follows the same pattern as the range key `:category [{:label "Food & Drinks", :facts {:db/id :product-filter, :filter-menu/selected "Food & Drinks", :product-filter/category "Food & Drinks"}}...`
Cool. That seems right assuming the string is an exact match for the category attribute of a product
Another debugging thing if you have a CLJS repl you can see the state that the views see with @precept.state/store. It’s also an object representation of the state in the session once the rules are done firing
ah yes, that's another thing I was looking for. Cool so at least I know my products are loaded and I can scratch that concern off my list
I can even see at the cljs repl (get-in @precept.state/store [:app :visible-product/id])
has products in it
oh!
Hm. Ok. Are they showing up under the products subscription as well?
how do I see that?
Should be in @precept.state/store near :precept.spec.sub/request :products
The id of the request should have a :precept.spec.sub/response with a map for the value
so if I do (keys @precept.state/store)
I should see a :precept.spec.sub/request key?
I think it’s keyed by UUID actually
Are you able to do a textual search within the REPL? That’s normally how I try to find things but I use IntelliJ which allows that
Another thing I might do in this situation is add a let block above the consequence of the sub and print what I’m looking for:
(defsub :products
....
=>
(let [_ (println "HEY" ?thing)
{:my-sub-as-it-exists ?foo...}
I got kind of excited to try this out right away so I just jumped in at the command line and didn't set it up as a proper project in intellij so I'm just editing with sublime
Oh nice. Didn’t know you could do that even
yeah, one command prompt for lein run and one for figwheel and just editing raw files with no context menus or helpers in sublime or notepad++
If the store prints reasonably in the browser console that might be another place that would allow find search
yeah I can console log at the repl and see what the browser says
Sorry for the difficulty. Dev tools have been near the top of my priorities but there’ I haven’t been able to find time to do it. For what it’s worth I think the information that we need for a better debug story is pretty much all there, we just need a better way to navigate and visualize it. This should be even more the case once we can redefine/alter rules and maintain the same state
yeah I wasn't expecting developer friendliness out the gate. I'm tempted to just scrap this code and start clean but I feel like I'll get more out of it if I keep banging my head against this wall until the wall cracks or my head does
it looks like the problem was my subscriptions were broken somehow. maybe there was a silent error somewhere that was keeping them from initializing.
Hm. Ok
You think they may not have initialized via the view, or that one wasn’t reporting results in the rules?
not sure, I'm going to try to reproduce now that I have it working again
well the cool thing is none of my category stuff broke it.
it was just from trying to include a truncated id in the description by doing (str (take 5 id) " description text")
in the product defn in views.cljs
basically the whole ui goes dead since I guess it breaks subscriptions.
then if you reload the page all the products disappear because the cache is cleared and it's not listening for products anymore
fixing the error and saving the file doesn't work. doing (reset-autobuild) in the cljs repl doesn't fix it either
lein clean doesn't seem to fix the issue either. This is a big issue since a small error can totally tank your whole dev flow.
Then again this just may be a cljs or figwheel workflow issue. I don't do a lot of development with clojurescript so I'm just swinging in the dark when trying to debug or fix an issue
@alex-dixon any considerations I should keep in mind while adding subscriptions in development? defsub doesn't seem to be repl driven development friendly either
😆 added a new dropdown for category filter. the value you click on shows up as the value for the price filter...EDIT: update this was fixed by using the correct keyword, :filter-menu2/selected, in the facts for the category menu options instead of :filter-menu/selected
maybe frontend development just isn't for me.
I think I've finally hit a problem that is precept related. I'm trying to implement multiple refinements like "toys under $10" and my current rules are like "okay, here are the toys, one for 80 and one for 8" so then I click on "$0 to $10" and it then goes "okay, here are those two toys again and every other product that's under $10"
then I click on "Health" category and it says "okay here are all the health products plus all the products under $10"
this also screws up the sorting lol