Coder Social home page Coder Social logo

bide's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bide's Issues

Url token Keywords with Hyphens

Hi,

In the README, there is an example:

(def routes
  [["/auth/login" :auth/login]
   ["/auth/recovery/token/:token" :auth/recovery]
   ["/workspace/:project-uuid/:page-uuid" :workspace/page]])

but I've found that bide doesn't currently work with hyphenated keywords like :project-uuid and :page-uuid. so:

(r/match router "/workspace/abc/def")
=> nil

Avoiding hyphenated keywords seems to do what we want.

(def routes
  [...
   ["/workspace/:projectuuid/:pageuuid" :workspace/page]])

(r/match router "/workspace/abc/def")
=> [:workspace/page {:projectuuid "abc", :pageuuid "def"}]

I'm assuming you want bide to be able to use hyphenated url keywords, so I think you'll have to change the parser regex.

query params keep on getting added to the end

I'm calling navigate! with the same route and params, but changing the 3rd argument, the query, causes a new set of query params to be added to the end of the URL. (instead of clearing out the previous keys).

For example, from the README if I do

(r/navigate! router :myapp/user-by-id {:id 2} {:foobar 1})
;; => "/api/users/2?foobar=1"

(r/navigate! router :myapp/user-by-id {:id 2} {:foobar 2})
;; => "/api/users/2?foobar=1?foobar=2"

navigate! appends query when using html5

When using :html5? true, the query gets appended to the the URL in the browser when using navigate!. The following generates a url ending with ?show-fields=true?show-fields=false?show-fields=true?show-fields=false?show-fields=true after toggling a few times. With :html5? false it works as expected.

(defn navigate! [view params query] 
  (debugf "Navigating to: %s" {:view view :params params :query query})
  (bide/navigate! router view params query))

(defn toggle-fields-visible! [{:keys [name params query]}]
  (navigate! name params (update query :show-fields #(if (= "true" %) "false" "true"))))

The output is:

DEBUG [xxx.core:31] - Navigating to: {:view :xxx/query-table, :params {:table-name "log"}, :query {:show-fields "false"}}

Nice library!

Warning due to resolve with clojurescript >= 1.9.660

Now that resolve exists in cljs.core, the compiler emits a warning:

WARNING: resolve already refers to: cljs.core/resolve being replaced by: bide.core/resolve at line 121 /main.out/bide/core.cljs

Could this be fixed with a quick (:refer-clojure :exclude [resolve]) in bide.core?

Simple Project Example

I'd very much like to use Bide, but can't seem to get it working. Would it be possible to provide an example project using bide to navigate between several simple pages?

Nested query params

Hi!

I have a question about how to best approach this; I'm basically trying to encode redirection data into a route. I thought it would go like this:

;; construct the login route and try to reconstruct the original data
(r/resolve router ::login {} {:redirect [::artist-view {:id 1}]})
;; => "/?redirect=artist-view&redirect=%7B%3Aid%201%7D"
(r/match router *1)
;; => [:user/login nil {:redirect ["artist-view" "{:id 1}"]}]

As you can see the structure of the vector gets destroyed. Can I hook into the encoding somehow? Is there a better approach that I'm not seeing?

Support for anchor tag - currently pollutes results

Love the library. Very simple to use. Did run into issues with anchors. if they are on the path then they leak into the produced results.

(def routes [["/" :root] ["/:id" :root-with-id]])
(def my-router (r/router routes))
(r/match my-router "/") ; [:root nil nil]
(r/match my-router "/?a=1") ; [:root nil {:a "1"}]
(r/match my-router "/?a=1#asdf") ; [:root nil {:a "1#asdf"}]
(r/match my-router "/#asdf") ; [:root-with-id {:id "#asdf"} nil]
(r/match my-router "/my-id#asdf") ; [:root-with-id {:id "my-id#asdf"} nil]
(r/match my-router "/my-id?a=1#asdf") ; [:root-with-id {:id "my-id"} {:a "1#asdf"}]

TypeError: null is not an object (evaluating '= this.hiddenInput_.value = token')

everytime I use navigate! I get the following error entry in the browser console:

TypeError: null is not an object (evaluating '= this.hiddenInput_.value = token') history.js:899
update_ history.js:899
check_ history.js:871
setHistoryState_ history.js:682
setToken history.js:621
(anonymous function) core.js:316
bide$core$_navigare core.js:16

it does not break things, but clutters the console output.

it seems that this 'hiddenInput' thing is specific to goog.History
Is there a reason why bide does not use goog.HTML5History?

Support for hot reload

First of all: Bide just works! It's great. Thank you!

I'm using shadow-cljs and that means frequent reloads of code.
However, I have to stuck any bide setup code in init (i.e. it only runs once), since it seems there's no stop! method and setting up another router leads to multiple registration of navigation events (i.e. after 4 re-loads any click on a route is done 4 times).

Would be great to have a stop! function to cleanup or a way to dynamically add routes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.