adopted-ember-addons / adopted-ember-addons/ember-cli-flash

preventDuplicates w/ custom dedupe property

未关闭
#337 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
355
派生
118
PR 合并指标
30 天内没有已合并 PR

描述

I would like to be able to specify what key I want my flash messages to be de-duped on - sometimes I'll have flashes with the same `message`, but they'll have a different characteristic that means they should still be shown.

eg
```
{ type: 'warning', area: 'maths', message: 'please update your students' }
{ type: 'warning', area: 'reading', message: 'please update your students' }
{ type: 'warning', area: 'maths', message: 'please update your students' }
```

I think this could work well - providing a `dedupe` property
```
{ type: 'warning', area: 'maths', message: 'please update your students', dedupe: `${area}-${message}` }
{ type: 'warning', area: 'reading', message: 'please update your students', dedupe: `${area}-${message}` }
{ type: 'warning', area: 'maths', message: 'please update your students', dedupe: `${area}-${message}` } // should be de-duped
```

`dedupe` could default to `${message}`, Then this could be changed to `dedupe`
https://github.com/poteto/ember-cli-flash/blob/49aec796a5123481f9b546cd53409455f38c0c41/addon/flash/object.js#L12-L13

Would this be a welcome/useful addition? should I write a PR for it?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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