Тёмный

Getting Started with Clojure Aliases 

Between Two Parens
Подписаться 1 тыс.
Просмотров 1,1 тыс.
50% 1

Getting Started with Clojure Aliases. This video will walk you through Clojure Aliases. What they are and how and when to use them.
This is the continuation of our ClojureScript Hello World app. We're going to evolve our project by adding Clojure aliases which make it easier to run our ClojureScript app for development.
😎 UPDATES
OCTOBER 08, 2020
As of the latest version of the Clojure CLI Tools, the command we run the app with was clj -A:dev but you SHOULD NOW USE clj -M:dev instead
⏰Timestamps:
00:24 - Intro
01:00 - Simple Alias Example - :main-opts
06:08 - Simple Alias Example 2 - :main-opts + :jvm-opts
08:09 - Corfield Comma
09:30 - Intro to global Clojure aliases
12:00 - Simple Alias Example 3 - :rebel
14:28 - Composing Aliases
15:38 - Eval in an Alias
18:10 - deps.en quick tips
📚Additional Resources
Clojure CLI Tools - betweentwopare...
Corfield comma - / 51-sean-corfield-aka-s...
deps cli reference - clojure.org/re...
Alias Examples - Sean - github.com/sea...
Alias Examples - Practicalli - github.com/pra...
❤️Follow Me
Twitter - / athomasoriginal
Between Two Parens Blog - betweentwopare...
Github - github.com/ath...

Опубликовано:

 

28 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 8   
@claytonmarshall1308
@claytonmarshall1308 4 года назад
I'm curious why the --eval option was passed to the rebel main-opts alias and not added as a main-opt in the async alias
@claytonmarshall1308
@claytonmarshall1308 4 года назад
I'll answer this myself since I think I've kind of figured it out. It seems the "--eval" flag is only useful when run alongside a main or "-m" specification (which makes way more sense now that I'm typing it). Providing main-opts for an alias that only serves to pull in extra dependencies is kind of pointless because...where is it supposed to evaluate the statement you gave it when you've provided no main to run? No where. I am surprised these aliases can't be composed together in a way that allows you to have simple dependency imports whose sole purpose is to import a library and then require it into your current namespace. That dependency alias itself couldn't be run alone, but would work in conjunction with an alias that had a main specified. Example: :aliases {:async {:extra-deps {org.clojure/core.async {:mvn/version "1.2.603"}} :main-opts ["--eval" "(require,'[clojure.core.async,:as,a])"]} :rebel {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"}} :main-opts ["-m" "rebel-readline.main"]} clj -A:async:rebel ;; runs a rebel main and also pulls in the async library clj -A:rebel ;; runs a regular rebel main - no additional libs required to run.
@BetweenTwoParens
@BetweenTwoParens 4 года назад
That's a good question. The reason we don't pass it into the `main-opts` in the `:async` alias is because while you can compose aliases and they will merge their dependencies correctly, the `main-opts` key does not, TMK, merge together when you combine aliases. So, if you write `clj -A:async:rebel` the `main-opts` from `:rebel` is the one that will be used. Now, as you may have noticed, this makes the `:rebel` alias problematic because you cannot run it without composing it with `:async`. It's for this reason, that I wouldn't recommend separating the `--eval` as I have done. This was meant to be a way to break things down for learning and also to illustrate some of the gotchas. So, what might be some alternatives? 1. Create aliases that already include all the deps you need + using the `-e` 2. Creates aliases that already have all the deps you need + provide a `user.clj` to perform your setup tasks. With this in mind, your dot-clojure is your personal file. That's what's great about it. So a good step forward is jamming on the aliases till you find ones that work for your particular workflow. Hopefully this answers the question? Let me know!
@claytonmarshall1308
@claytonmarshall1308 4 года назад
​@@BetweenTwoParens Yeah! My answer above was close to this, but your explanation provided more details and good alternatives as well, so I feel much better about this. Thanks!
@shundeev
@shundeev 4 года назад
Thank you, you are my savior.
@ilyushka21st
@ilyushka21st 4 года назад
Thanks, helpful as usual! Off-topic: what the extra keyboard you use?
@BetweenTwoParens
@BetweenTwoParens 4 года назад
Thanks, Illia! The keyboard is a Gk64. Bought it from keyboard fans. www.mechtype.com/gk64-review/
@ilyushka21st
@ilyushka21st 4 года назад
@@BetweenTwoParens Sweet, good to know
Далее
Get Started with CLJS + Figwheel-Main
21:08
Просмотров 2,4 тыс.
How to use NPM Packages in ClojureScript
11:29
Просмотров 1,6 тыс.
Setup Reagent And ClojureScript
12:19
Просмотров 1,5 тыс.
Writing a game the hard way - from scratch using C. #1
34:20
Being Competent With Coding Is More Fun
11:13
Просмотров 81 тыс.
Gitlab DELETING Production Databases | Prime Reacts
17:27
How to use React in a ClojureScript project | beginner
14:33
Vim Tips I Wish I Knew Earlier
23:00
Просмотров 67 тыс.