This is how I imagine(d) that SAFE works, and how I would like the example to be like

<!DOCTYPE html>
<html>
	<head>
		<title>Minimal SAFE example</title>
		<!--

			This is added by the SAFE Browser itself, internally:
			<script src="maidsafe.js">

		--!>
	</head>
	<body>
		<p id="output"></p>
		<button id="button">Click me to add a piece of data and then fetch and display it</button>
		<script>

			function fetchAndDisplayContents()
			{
				SAFE.getTextFromContainer('my cool blog day 1', function(e)
				{
					if (e.value)
					{
						document.getElementById('output').innerHTML = 'Output: ' + e.value;
					}
				});
			}

			fetchAndDisplayContents();

			document.getElementById('button').addEventListener('click', function(e)
			{
				SAFE.createTextContainer('my cool blog day 1', 'Today, I made a minimal SAFE example, hoping to transform the current SAFE example from incomprehensible to logical and straight-forward.');
				fetchAndDisplayContents();
			});

		</script>
	</body>
</html>

Naturally, this won’t run, because it’s just pseudo code from my basic understanding of what SAFE is and how I want it to be. This is what I expected to see when I loaded the example “web app” on the developer site, but instead, I just saw a ton of weird stuff that seems completely alien to me. I truly want to start using this thing, but I literally cannot understand any of the documentation.

3 Likes

What are you talking about? show some examples.

4 Likes

It sounds like you want something closer to hello world, than a more advanced Vue based app in the tutorial.

Moreover, it sounds like a wrapper to hide away some of the complexity would help. The tutorial looks to actually create one, but you have to build it from the tutorial. Perhaps this high level functionality should be wrapped into a basic wrapper library?

Perhaps there should be some more simple examples that build up to this? People will be coming into this project at all levels and as it is a new way of writing web apps, starting basic will do no harm.

Personally, I like the way the dev tutorial walks you through creating something reasonably complex. It shows the inner workings, which is useful for building more complex apps. This may not suit how everyone works though and we should be conscious of this.

17 Likes

Yeah check out my BabySAFE js wrapper on my WhiteOutMashups Github

6 Likes

But what’s the purpose of this?

The goal of this project is to make the #1 EASIEST API for the SAFE Network, so anyone can copy and paste WORKING BUTTONS into their projects / apps / websites.

So it’s not about an API, but about buttons and copy-and-paste-code?

yeah, the api feels like a c wrapper, no classes, the context needs to be passed into functions as an argument.

2 Likes

Sorry… I don’t understand BabySAFEapi either. What’s with all this boilerplate code?

The pseudo-code in OP is basically what goes on in safe://todo (except it saves a JSON string). It’s code is here: Safe-todo-draw/safe.js at master · wardbr/Safe-todo-draw · GitHub.

3 Likes

… huh? Did you link to the right file? Are you making a joke?

The Safe-todo-draw Github project has also the index.html that sources the safe.js file that drehb refers to. Like the maidsafe.js that you sourced in your pseudo code in the OP. You can find this index.html easily in the Github project. I’m not sure if this is what you’re looking for, but maybe it will help (a bit). In safe://todo, there is a Vue.js ‘layer’ in between, but you could use safe.js (or something like it) without the Vue.js-part.
So no joke, only drehb who wanted to help you.

2 Likes

We don’t seem to be speaking the same language. Whatever I ask or say, I get very strange replies that seem to somehow ignore what I say yet at the same time appear to be answering them. I have no idea what to make of any of this.

Let me just repeat: I have no clue how to code something for SAFE after reading the “example” app.

If you want results, you should try to be more specific about what is not clear to you or what can be improved according to you, I think.
What I think to understand from you is that you find that the Safe example web app should look more like the pseudo code in your OP or something like that.
In the responses you got, other examples than the Safe example web app were mentioned. Examples that maybe resemble more your pseudo code.

1 Like

And I looked at those, and replied that they aren’t. Why even link to them in the first place when it’s no more logical?

I literally have no idea how to use/code for SAFE. How do you think this thing will ever take off if I, who isn’t a beginner coder in any sense, have no idea what to do? It’s almost as if you don’t even understand what I’m talking about.

Frankly I don’t. It doesn’t make sense to me that you say you are experienced, yet don’t appear to be able to say what it is you need help with, and lack the ability to research anything or make any progress despite the resources available, and the people trying to help.

Lots of people have come to this project with little knowledge and experience, and when there where with fewer resources to help they have still managed to get off the ground. One even gave a presentation at the DevCon.

Things are much clearer now and there are people who have been through that trying to help you.

So there’s a gap here, and as I’ve said, I don’t understand what it is and I don’t think others here do either.

You saying “I’m experienced and I don’t understand any of this” isn’t working, so maybe you can do better than that. Help others to help you.

You could start by explaining why as an experienced coder you don’t understand any of this. Why not? What is your experience? If there’s nothing you understand, this doesn’t make sense, so it leaves people confused as to how to help.

Why can’t you make sense of that code? It’s just code.

There’s a problem obviously, but I have no idea what it is, and so no idea how to help you with it. Can you understand that?

14 Likes

There is nothing strange with the sample you suggest @EvilMaid. It is quite normal that heavily used API:s get very simplified, in wrappers or libraries, where some freedom is exchanged for convenience.

The C# code I’ve written to exemplify a SAFENetwork based event store, does exactly this (but in an event sourcing context).

So, your suggestion:

SAFE.getTextFromContainer('my cool blog day 1', function(e)
				{
					if (e.value)
					{
						document.getElementById('output').innerHTML = 'Output: ' + e.value;
					}
				});

This is neat, and this is what it should look like for a large portion of users. But obviously it is not there currently. No need to get so worked up about it.

Personally I think you have a really negative approach. You could say what you want to say, without the passive aggression.

You could just as well have said:
“Hey guys! I don’t get the examples, I would like to see it like this [your example]. That would make it very easy to understand and use IMO. What do you think? If it doesn’t exist, is there anyone out there who would like to do it? I would’ve loved to do it myself, but can’t because of [whatever reason].”

You would have gotten friends immediately here, and maybe also that simplified code. The path to your desired results are much longer now with the approach you chose :slight_smile:

10 Likes

OK…let me try to break down the code that I linked for you. You can pretty much use that code directly with a few small modifications to accomplish what you wanted, which I interpreted to be storing and possibly later modifying a string.

on line 11: const SAFE_LIST_KEY = ‘key_TodoMVC’

this is the key that is used to identify the data entry. As you see on lines 47 and 78, this entry is in the user’s public container. You can change line 11 to:

const SAFE_LIST_KEY = ‘key_EvilMaidDiary’

You should also customize the appInfo on lines 72 - 75.

In your pseudo-code, getTextFromContainer corresponds to GetListEntrySafe in the code that I linked, and createTextContainer corresponds to setList. Add in a call to init when your page loads and you should be well on your way.

3 Likes

Maybe you are such incredible geniuses that you simply cannot understand that not everyone has your vast and deep knowledge about everything, but again, these replies don’t make any sense to me, just as that code (Safe-todo-draw/safe.js at master · wardbr/Safe-todo-draw · GitHub) doesn’t make any sense.

Is this some elaborate “joke”? Are you reading what you want to read instead of what I type? Why is there not a single coherent example on how to use SAFE, or even seemingly any API to use? Why is my example not how you use SAFE? If you want to be taken seriously, things are going to have to change drastically.

I really feel as if I’m not getting through here. To call it “frustrating” would be an extreme understatement. I honestly think that you’ve become a very tight group and (perhaps subconsciously) exclude “outsiders” by making it impossible to understand the documentation. I’ll just have to take your word for it that some people have allegedly figured it out anyway, but I suspect that is only true for a small handful of people who have followed SAFE from day one.

If you want this project to ever go anywhere, extreme usability for all users, including developers, is an absolute requirement. I’m not here to tell you what you want to hear, so the SAFE network can be released in year 2040 or something, but what you need to hear if you actually want anyone to make anything for SAFE, because as it stands, it takes skills that almost nobody has.

My serious advice: Get an API finalized and stable ASAP, and make it dead-simple to use without exposing weird, unnecessary internals. Then and only then will anyone besides a handful of hardcore SAFErs care.

2 Likes

So, you want hello world for beginners. I think we all get that and people have tried to bridge that gap for you. I am sure the dev hub will include such examples in the future.

In return, you have been rude and blamed everyone but yourself. Pro tip: if you want help, be modest and respectful to those who can provide it.

8 Likes

I’ve explained why I think we’re finding it impossible to help you.

You’ve responded by repeating the same complaints and adding to them, but have not answered any of my questions which were constructive, designed to shed light and break this deadlock.

This is pointless unless you can engage seriously and constructively.

4 Likes

I’m the one person who hasn’t been rude.

But since I can tell that you don’t want SAFE to succeed, I’ll stop trying to pull out basic documentation from you and let this project fail on its own.

SAFE doesn’t exist outside your dream world, but you won’t even admit this when you are old and grey. You’ll still keep chanting the same nonsense.

There’s another tutorial on the dev forum that could help perhaps

Webapp Example #2 creates some data then prints it to the console. Maybe there’s some API changes since the tutorial was written though.

2 Likes