Skip to content

Commit 1c2c292

Browse files
committed
Make UID actually unique & add an assign method
1 parent d3adaf4 commit 1c2c292

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dev/src/utils/UID.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
1818

1919
let UID = {
2020
_next: 0,
21-
get id() { return this._next++; }
21+
get id() { return Date.now() + "_" + this._next++; },
22+
assign(list, force=false) {
23+
list.forEach((o) => o.id = o.id == null || force ? this.id : o.id );
24+
}
2225
};
2326
export default UID;
2427

0 commit comments

Comments
 (0)