Coder Social home page Coder Social logo

[Feature Request] ReadOnly Box about hive HOT 10 CLOSED

isar avatar isar commented on July 3, 2024 3
[Feature Request] ReadOnly Box

from hive.

Comments (10)

X-Wei avatar X-Wei commented on July 3, 2024 2

Thanks @fredrikbaberg !

But explicitly adding read-only boxes would be helpful, e.g. we could make concurrent access to read-only boxes possible. @leisim WDYT?

from hive.

simc avatar simc commented on July 3, 2024

I will look into this...

from hive.

bolasim avatar bolasim commented on July 3, 2024

I would also find this super helpful. Let me know if you need a hand.

from hive.

bolasim avatar bolasim commented on July 3, 2024

Any update on this? Also, if this is implemented, can you read directly from assets (for flutter) instead of having to copy over the box?

from hive.

simc avatar simc commented on July 3, 2024

@re-bola I'm still working on this and yes you will be able to open a box directly from the assets. It will look somehow like this:

var bytes = rootBundle.load('assets/myBox.hive');
var box = Hive.openBoxFromBytes('myBox', bytes);

Would that be okay?

from hive.

bolasim avatar bolasim commented on July 3, 2024

Looks good. Will it still support LazyBoxes?

from hive.

simc avatar simc commented on July 3, 2024

Not in combination with read only boxes from bytes. It makes no sense since you cannot write to boxes from bytes anyways...

But the regular lazy boxes will still be there...

from hive.

simc avatar simc commented on July 3, 2024

This has been resolved in v1.1.0. You can use Hive.openBoxFromBytes().

from hive.

X-Wei avatar X-Wei commented on July 3, 2024

Seems openBoxFromBytes() method is not present in hive v2.0 -- how can we open a box in read-only mode now?

from hive.

fredrikbaberg avatar fredrikbaberg commented on July 3, 2024

@X-Wei I think the bytes argument should be used now. Not sure where I saw it described, but it's what I'm using in my current project. You could try the following code snippet; I've only tested it targeting Windows in debug mode but hope it helps.

var _bytes = await rootBundle
            .load(path)
            .then((value) => value.buffer.asUint8List());
        _box = await Hive.openBox(
          name,
          bytes: _bytes,
        );

from hive.

Related Issues (20)

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.