Fork me on GitHub
#precept
<
2017-07-05
>
alex-dixon14:07:26

@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

alex-dixon14:07:03

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

alex-dixon14:07:41

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

gdeer8115:07:46

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

alex-dixon15:07:30

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

alex-dixon15:07:06

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

alex-dixon15:07:51

I might also write a rule that just prints visible product ids

alex-dixon15:07:20

Not saying you should just letting you know what I might do faced with the same problem

alex-dixon15:07:40

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

alex-dixon15:07:59

@gdeer81 I’m assuming you’re testing with no facts about the filters in the session?

alex-dixon15:07:15

(in which case all products should be visible instead of none of them)

gdeer8115:07:28

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"}}...`

alex-dixon15:07:41

Cool. That seems right assuming the string is an exact match for the category attribute of a product

alex-dixon15:07:10

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

gdeer8115:07:29

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

gdeer8115:07:43

I can even see at the cljs repl (get-in @precept.state/store [:app :visible-product/id]) has products in it

alex-dixon15:07:31

Hm. Ok. Are they showing up under the products subscription as well?

gdeer8115:07:18

how do I see that?

alex-dixon15:07:04

Should be in @precept.state/store near :precept.spec.sub/request :products

alex-dixon15:07:42

The id of the request should have a :precept.spec.sub/response with a map for the value

gdeer8115:07:46

so if I do (keys @precept.state/store) I should see a :precept.spec.sub/request key?

alex-dixon15:07:14

I think it’s keyed by UUID actually

alex-dixon15:07:46

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

alex-dixon15:07:56

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...}

gdeer8115:07:34

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

alex-dixon15:07:01

Oh nice. Didn’t know you could do that even

gdeer8115:07:45

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++

alex-dixon15:07:51

If the store prints reasonably in the browser console that might be another place that would allow find search

gdeer8115:07:38

yeah I can console log at the repl and see what the browser says

alex-dixon15:07:21

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

gdeer8116:07:09

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

gdeer8116:07:33

it looks like the problem was my subscriptions were broken somehow. maybe there was a silent error somewhere that was keeping them from initializing.

alex-dixon17:07:24

You think they may not have initialized via the view, or that one wasn’t reporting results in the rules?

gdeer8117:07:12

not sure, I'm going to try to reproduce now that I have it working again

gdeer8117:07:19

well the cool thing is none of my category stuff broke it.

gdeer8117:07:04

it was just from trying to include a truncated id in the description by doing (str (take 5 id) " description text")

gdeer8117:07:20

in the product defn in views.cljs

gdeer8117:07:36

basically the whole ui goes dead since I guess it breaks subscriptions.

gdeer8117:07:18

then if you reload the page all the products disappear because the cache is cleared and it's not listening for products anymore

gdeer8117:07:10

fixing the error and saving the file doesn't work. doing (reset-autobuild) in the cljs repl doesn't fix it either

gdeer8118:07:38

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.

gdeer8118:07:53

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

gdeer8120:07:08

@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

gdeer8121:07:16

😆 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

gdeer8121:07:49

maybe frontend development just isn't for me.

gdeer8121:07:10

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"

gdeer8121:07:45

then I click on "Health" category and it says "okay here are all the health products plus all the products under $10"

gdeer8121:07:21

this also screws up the sorting lol