binaryage / binaryage/cljs-devtools

Feature: String with metadata mode

未关闭
#57 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Clojure
星标
1.1k
派生
51
PR 合并指标
30 天内没有已合并 PR

描述

This is a feature idea.

I'm looking for a way to make my js/console.log display cleanly with and without cljs-devtools installed.

## Motivating example

Today's job is a react native app. It's not always convenient to turn cljs-devtools on (e.g. two simulators) and it's helpful to look in the simulator logs sometimes (no cljs-devtool rendering).

## Problems
* js/console.log with regular clojure data types produces verbose/unreadable strings.
* logging (serializing) large data structures can cause UX lag

## Idea

Perhaps cljs-devtools could be adapted to look for metadata associated with a string (or string like) object.

Vaguely something like this could be used to prepare a "console.log friendly string" with some other protocol which cljs-devtools could detect...

```cljs
(defn data-str [data]
(binding [*print-level* 3 *print-length* 5]
(specify! (pr-str data) IMeta (-meta [_] data)))))

(js/console.log (data-str {:a 1 :b (range 1000)}))
```

NOTE: this code doesn't work

Goal is to cover two cases
* String form will work in all situations and not take too long to serialize.
* If cljs-devtools is installed you can drill into metadata.

贡献指南

这个仓库没有索引到贡献指南

调研方向

issue 中没有指定实现文件或测试。首先跟踪 js/console.log 路径以及 cljs-devtools 对值的处理方式,然后评估提议的 data-str 元数据方案;完成的标准是:无需 cljs-devtools 即可进行有界序列化,同时已安装的 cljs-devtools 可以深入查看关联数据。

由索引模型根据 Issue 内容生成。

评估

技术栈
clojure, javascript, react-native
领域
devtools
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。